The Repo Module
Now that we’ve got a handle on what a Repository is, let’s look at how it’s implemented in Ecto. The Repo module is the heart of Ecto, and just about everything you do will touch Repo in some way. Repo is also quite powerful; as you’re about to see, you can perform all of the classic CRUD operations (create, read, update, delete) using just the Repo module alone. The other modules in Ecto make these operations easier, but there’s a lot you can do with just Repo.
Given its relationship to the Repository pattern, Repo contains a lot of functions you’d expect: get, insert, update, delete, and the like. What you might not expect is that you never call these functions directly. Instead, you create your own Repo module that lives ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access