Ecto Changesets
From ElixirBlocks
This page is in progress
Ecto.Repo.insert/2, update/2 and delete/2 require a changeset as their first parameter. The creating, updating or deleting of table data always requires a changeset.
Changesets can be created using the data from a table schema.
Using Ecto.Changeset.cast
Ecto.Changeset.cast(%Friends.Person{name: "Bob"}, %{"name" => "Jack"}, [:name, :age])
The previous code takes three arguments.
- The Schema
- the change you want to make to the data
- The names of the fields that you are allowed to change (as a list of atoms)