2021-08-11 21:58:28 +00:00
|
|
|
defmodule Ketbin.Pastes.Paste do
|
|
|
|
use Ecto.Schema
|
|
|
|
import Ecto.Changeset
|
|
|
|
|
2021-08-11 22:59:58 +00:00
|
|
|
@primary_key {:id, :string, autogenerate: false}
|
|
|
|
@derive {Phoenix.Param, key: :id}
|
2021-08-11 21:58:28 +00:00
|
|
|
schema "pastes" do
|
|
|
|
field :content, :string
|
|
|
|
field :is_url, :boolean, default: false
|
|
|
|
field :belongs_to, :id
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc false
|
|
|
|
def changeset(paste, attrs) do
|
|
|
|
paste
|
2021-08-11 22:59:58 +00:00
|
|
|
|> cast(attrs, [:is_url, :content, :id])
|
2021-08-11 21:58:28 +00:00
|
|
|
|> validate_required([:is_url, :content])
|
|
|
|
end
|
|
|
|
end
|