Working with Associations

So far, all of our changesets have been using a single schema. But you will often need to update associated records as well as parent records at the same time. Ecto provides a number of options for updating associated records, each serving a particular purpose depending on where your data is coming from and how you want it updated. In this section, we’ll look at the various ways we can insert and update Artist records along with associated Album records.

Updating a Single Associated Record

When making changes to child records, the first question to ask yourself is if you want to make changes to an individual child record, or if you want to change the entire collection of associated records at once. If you want to work ...

Get Programming Ecto now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.