April 2019
Beginner to intermediate
244 pages
6h 34m
English
Now that we’ve got the sample app up and running, we’re ready to begin our tour of Ecto. We’re going to start with the big picture and take a look at Ecto’s approach to database access. Ecto adopts the Repository pattern for accessing the underlying data store. Understanding this pattern will help make sense of Ecto’s overall architecture, so let’s take a quick look.
Open a mix session in the music_db app we set up in the last section: iex -S mix. Then type in the following lines of code (you don’t have to enter the comments—that’s just to help clarify what’s going on):
| | alias MusicDB.{Repo, Artist} |
| | |
| | # insert a record into the artists table |
| | Repo.insert(%Artist{ ... |
Read now
Unlock full access