typespec some models
This commit is contained in:
parent
bd6c05f619
commit
f12e71cbe2
@ -6,9 +6,9 @@ defmodule Cannery.Containers.Container do
|
|||||||
@primary_key {:id, :binary_id, autogenerate: true}
|
@primary_key {:id, :binary_id, autogenerate: true}
|
||||||
@foreign_key_type :binary_id
|
@foreign_key_type :binary_id
|
||||||
schema "containers" do
|
schema "containers" do
|
||||||
|
field :name, :string
|
||||||
field :desc, :string
|
field :desc, :string
|
||||||
field :location, :string
|
field :location, :string
|
||||||
field :name, :string
|
|
||||||
field :type, :string
|
field :type, :string
|
||||||
|
|
||||||
belongs_to :user, Accounts.User
|
belongs_to :user, Accounts.User
|
||||||
@ -16,6 +16,18 @@ defmodule Cannery.Containers.Container do
|
|||||||
timestamps()
|
timestamps()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@type t :: %{
|
||||||
|
id: Ecto.UUID.t(),
|
||||||
|
name: String.t(),
|
||||||
|
desc: String.t(),
|
||||||
|
location: String.t(),
|
||||||
|
type: String.t(),
|
||||||
|
user: Accounts.User.t(),
|
||||||
|
user_id: Ecto.UUID.t(),
|
||||||
|
inserted_at: NaiveDateTime.t(),
|
||||||
|
updated_at: NaiveDateTime.t()
|
||||||
|
}
|
||||||
|
|
||||||
@doc false
|
@doc false
|
||||||
def changeset(container, attrs) do
|
def changeset(container, attrs) do
|
||||||
container
|
container
|
||||||
|
@ -10,26 +10,27 @@ defmodule Cannery.Invites.Invite do
|
|||||||
field :token, :string
|
field :token, :string
|
||||||
field :uses_left, :integer, default: nil
|
field :uses_left, :integer, default: nil
|
||||||
field :disabled_at, :naive_datetime
|
field :disabled_at, :naive_datetime
|
||||||
|
|
||||||
belongs_to :user, Accounts.User
|
belongs_to :user, Accounts.User
|
||||||
|
|
||||||
timestamps()
|
timestamps()
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc false
|
|
||||||
def changeset(invite, attrs) do
|
|
||||||
invite
|
|
||||||
|> cast(attrs, [:name, :token, :uses_left, :disabled_at, :user_id])
|
|
||||||
|> validate_required([:name, :token, :user_id])
|
|
||||||
|> validate_number(:uses_left, greater_than_or_equal_to: 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
@type t :: %{
|
@type t :: %{
|
||||||
id: Ecto.UUID.t(),
|
id: Ecto.UUID.t(),
|
||||||
name: String.t(),
|
name: String.t(),
|
||||||
token: String.t(),
|
token: String.t(),
|
||||||
uses_left: integer() | nil,
|
uses_left: integer() | nil,
|
||||||
disabled_at: NaiveDateTime.t(),
|
disabled_at: NaiveDateTime.t(),
|
||||||
user_id: Ecto.UUID.t(),
|
user: Accounts.User.t(),
|
||||||
user: Accounts.User.t()
|
user_id: Ecto.UUID.t()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def changeset(invite, attrs) do
|
||||||
|
invite
|
||||||
|
|> cast(attrs, [:name, :token, :uses_left, :disabled_at, :user_id])
|
||||||
|
|> validate_required([:name, :token, :user_id])
|
||||||
|
|> validate_number(:uses_left, greater_than_or_equal_to: 0)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -6,8 +6,8 @@ defmodule Cannery.Tags.Tag do
|
|||||||
@primary_key {:id, :binary_id, autogenerate: true}
|
@primary_key {:id, :binary_id, autogenerate: true}
|
||||||
@foreign_key_type :binary_id
|
@foreign_key_type :binary_id
|
||||||
schema "tags" do
|
schema "tags" do
|
||||||
field :bg_color, :string
|
|
||||||
field :name, :string
|
field :name, :string
|
||||||
|
field :bg_color, :string
|
||||||
field :text_color, :string
|
field :text_color, :string
|
||||||
|
|
||||||
belongs_to :user, Accounts.User
|
belongs_to :user, Accounts.User
|
||||||
@ -15,6 +15,17 @@ defmodule Cannery.Tags.Tag do
|
|||||||
timestamps()
|
timestamps()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@type t :: %{
|
||||||
|
id: Ecto.UUID.t(),
|
||||||
|
name: String.t(),
|
||||||
|
bg_color: String.t(),
|
||||||
|
text_color: String.t(),
|
||||||
|
user: Accounts.User.t(),
|
||||||
|
user_id: Ecto.UUID.t(),
|
||||||
|
inserted_at: NaiveDateTime.t(),
|
||||||
|
updated_at: NaiveDateTime.t()
|
||||||
|
}
|
||||||
|
|
||||||
@doc false
|
@doc false
|
||||||
def changeset(tag, attrs) do
|
def changeset(tag, attrs) do
|
||||||
tag
|
tag
|
||||||
|
Loading…
Reference in New Issue
Block a user