Ecto Overview: The Repo

Ecto is the overwhelmingly dominant database library for Elixir.

The most important thing to understand about Ecto is that it uses a repository pattern. It's a fundamentally different way of working with a database than Active Record which you may be used to from Rails, Laravel or other frameworks. There are both advantages and disadvantages.

In essence the repo acts like a border agent between you and your database. Anytime you want to read or write through the database, you go through the repo. It never dissolves into the background the way Active Record and some other ORMs do.

This can feel a little bit tedious at the beginning, but you will be very aware of when and how you're querying your database and will have a much easier time understanding your system as it grows.

To see this full series on YouTube, use this playlist.

Back to index

No Comments