April 2024
Beginner to intermediate
224 pages
5h 7m
English
Now that we have schemas, we need a way to insert data into the database. The approach that Ecto takes is significantly different than ActiveRecord, but it’s one of the most loved components of Ecto. Let’s dive into Ecto changesets.
Ecto.Changeset[54] lets us turn data parameters into a persisted database record. Changesets are used for creating new records or updating existing records. We can also validate incoming data using changesets—this ensures our database records match our application’s business rules.
Let’s write our first changeset. We’ll start with the Contact schema because it has fewer fields.
The functional nature of Elixir is visibly seen in the changeset function we’re ...
Read now
Unlock full access