April 2019
Beginner to intermediate
244 pages
6h 34m
English
To try out embeds, we’re going to veer slightly from the data model we’ve been working with so far. We’re going to create a new Album schema. This one will use embeds, rather than associations, to handle the child records for Artist and Track. The relationships will still be the same (that is, albums will have have one artist, and have many tracks) but we’ll model these relationships using embeds.
To keep this approach distinct in our codebase, we’ll create new schemas with different names. Let’s start with tracks.
You define embeds similarly to normal schemas, but you don’t provide a name for the source table, since they belong to no particular table:
| | defmodule MusicDB.TrackEmbed ... |
Read now
Unlock full access