April 2019
Beginner to intermediate
244 pages
6h 34m
English
To solve our problem, we’ll create two new table-less schemas: one for SoloArtist and another for Band. We’ll use these schemas to collect user input, and then translate them into Artist records when it’s time to store them.
First, let’s set up our new schemas:
| | defmodule MusicDB.SoloArtist do |
| | use Ecto.Schema |
| | import Ecto.Changeset |
| | |
| | embedded_schema do |
| | field :name1, :string |
| | field :name2, :string |
| | field :name3, :string |
| | field :birth_date, :date |
| | field :death_date, :date |
| | end |
| | end |
| | defmodule MusicDB.Band do |
| | import Ecto.Changeset |
| | use Ecto.Schema |
Read now
Unlock full access