Put Our Repo to Work

Learn how the Repo module works.

We'll cover the following

As seen earlier, Repo is the gateway to our database and most of the functions in Repo map directly to standard CRUD operations. This makes Repo reasonably small compared to some other Ecto modules. It’s one job is sending payloads back and forth to the database. Yet we can use this small handful of functions to create, read, update, and delete records. Let’s try it.

The Repo module exposes several functions that allow us to interact with our database at a low level, even before setting up schemas. These functions are easy to spot because they end with “all,”like insert_all, update_all, delete_all, and just plain all for queries.

Insert

Our music application includes an artists table. Here’s how we can insert a new record into that table.

Get hands-on with 1200+ tech skills courses.