Create Your Repo Module

Learn how to create the repository module for your app.

Next, we need to create our application’s repository module. We went through this process in detail before, but we’ll run through it again here.

Creating repo.ex file

Open a new file called lib/my_app/repo.ex and add the following:

Press + to interact
defmodule MyApp.Repo do
use Ecto.Repo,
otp_app: :my_app,
adapter: Ecto.Adapters.Postgres
end

Explanation

The use Ecto.Repo directive will make our module a bona fide Ecto repository—all of Ecto’s repository functions will be defined and made available on this module. For more details on how this works, see ...