forked from shibao/cannery
add models, context and liveviews
This commit is contained in:
23
lib/cannery/containers/container.ex
Normal file
23
lib/cannery/containers/container.ex
Normal file
@ -0,0 +1,23 @@
|
||||
defmodule Cannery.Containers.Container do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
@primary_key {:id, :binary_id, autogenerate: true}
|
||||
@foreign_key_type :binary_id
|
||||
schema "containers" do
|
||||
field :desc, :string
|
||||
field :location, :string
|
||||
field :name, :string
|
||||
field :type, :string
|
||||
field :user_id, :binary_id
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
@doc false
|
||||
def changeset(container, attrs) do
|
||||
container
|
||||
|> cast(attrs, [:name, :desc, :type, :location])
|
||||
|> validate_required([:name, :desc, :type, :location])
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user