Create Table-less Schemas
Learn how to create table-less schemas.
We'll cover the following...
Create two schemas
We’ll create two new table-less schemas to solve our problem—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.
Press + to interact
defmodule MusicDB.SoloArtist doimport Ecto.Changesetuse Ecto.Schemaembedded_schema dofield :name1, :stringfield :name2, :stringfield :name3, :stringfield :birth_date, :datefield :death_date, :dateendend
Press + to interact
defmodule MusicDB.Band doimport Ecto.Changesetuse Ecto.Schemaembedded_schema dofield :name, :stringfield :year_started, :integerfield :year_ended, :integerendend
For the most part, these look quite a lot like ...