Search⌘ K

Put Our Repo to Work

Explore how to use the Repo module in Elixir with Ecto to perform basic CRUD operations on your database. Learn to insert new records, update existing ones using update_all functions, and delete records using delete_all. This lesson helps you understand how to interact with your database effectively before diving into schemas.

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 ...