After 'mix phx.gen.live Items Item items name:string description:string info:string amount:integer factor:float type:string'

This commit is contained in:
2026-04-21 13:29:13 +02:00
parent e930c742b5
commit 851665ef60
10 changed files with 698 additions and 0 deletions

View File

@ -0,0 +1,26 @@
defmodule GenericRestServer.Items.Item do
use Ecto.Schema
import Ecto.Changeset
@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
schema "items" do
field :name, :string
field :description, :string
field :info, :string
field :amount, :integer
field :factor, :float
field :type, :string
field :user_id, :binary_id
timestamps(type: :utc_datetime)
end
@doc false
def changeset(item, attrs, user_scope) do
item
|> cast(attrs, [:name, :description, :info, :amount, :factor, :type])
|> validate_required([:name, :description, :info, :amount, :factor, :type])
|> put_change(:user_id, user_scope.user.id)
end
end