The Repository Pattern
Explore the repository pattern as used in Ecto for Elixir to manage database interactions. Understand how this pattern centralizes database access through a single module, enhancing clarity and control compared to other data access methods. Learn to insert, retrieve, update, and delete records via the Repo module and see why this approach suits Elixir’s explicit and decoupled design.
Ecto’s approach to database access
Now that we’ve got the sample application up and running, we’re ready to begin our tour of Ecto. We’re going to start with the big picture and look at Ecto’s approach to database access. Ecto adopts the repository pattern to access the underlying data store. Once we understand this pattern, it’ll help make sense of Ecto’s overall architecture. Let’s take a quick look.
We’ll open a mix session in the music_db application we set up in the last section, iex -S mix ...