Customizing Your Repo
For many projects, you won’t need to do much to your Repo module. With that one use Ecto.Repo call, you’ll have access to everything you need. But there may be times when you find yourself calling some particular Repo functions over and over with the same set of options, or maybe you’d like to add some behavior that Repo doesn’t currently have. Fortunately, the Repo module you created is a plain old Elixir module just like any other, so it’s possible to add customized behavior just by adding more functions.
For example, we might decide that we’re going to be doing a lot of counting in our music app: how many albums we have, how many artists, and so forth. Getting the number of records in a table is fairly easy with Repo ...
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