April 2019
Beginner to intermediate
244 pages
6h 34m
English
Next we need to create our app’s repository module. We went through this process in detail in Chapter 1, Getting Started with Repo but we’ll run through it again here.
Open a new file called lib/my_app/repo.ex and add the following:
| | defmodule MyApp.Repo do |
| | use Ecto.Repo, |
| | otp_app: :my_app, |
| | adapter: Ecto.Adapters.Postgres |
| | end |
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 The Repo Module.
The otp_app: :my_app option tells Ecto where to find the repository configuration. So far, our project only has the my_app application, ...
Read now
Unlock full access