Skip to content

Instantly share code, notes, and snippets.

@shankardevy
Created July 8, 2017 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shankardevy/f667df4835735621b92ef66058059b23 to your computer and use it in GitHub Desktop.
Save shankardevy/f667df4835735621b92ef66058059b23 to your computer and use it in GitHub Desktop.
defmodule Mango.Sales.Order do
use Ecto.Schema
import Ecto.Changeset
alias Mango.Sales.Order
schema "orders" do
field :line_items, {:array, :map}
field :status, :string
field :total, :decimal
timestamps()
end
@doc false
def changeset(%Order{} = order, attrs) do
order
|> cast(attrs, [:status, :total, :line_items])
|> validate_required([:status, :total, :line_items])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment