Work with Associations
Explore how to update and insert associated records in Ecto with changesets and build_assoc. Understand when to modify individual child records directly versus updating collections, and learn how to insert new associations using Repo in Elixir.
We'll cover the following...
We'll cover the following...
So far, all of our changesets have used a single schema. However, we’ll often need to update associated records as well as parent records at the same time. Ecto provides several options for updating associated records, each serving a particular purpose depending on where our data is coming from and how we want it updated. This section will look at how we can insert and update Artist records and associated Album records.
Updating a single associated record
When making changes to child records, ...