#--- # Excerpted from "Programming Ecto", # published by The Pragmatic Bookshelf. # Copyrights apply to this code. It may not be used to create training material, # courses, books, articles, and the like. Contact us if you are in doubt. # We make no guarantees that this code is fit for any purpose. # Visit https://pragprog.com/titles/wmecto for more book information. #--- defmodule MusicDB.TrackEmbed do import Ecto.Changeset use Ecto.Schema embedded_schema do field(:title, :string) field(:duration, :integer) end def changeset(track_embed, params) do track_embed |> cast(params, [:title, :duration]) |> validate_required([:title]) end end