add notes

This commit is contained in:
2022-07-25 20:08:40 -04:00
parent 1a423f703b
commit 63fca7ff6a
14 changed files with 607 additions and 12 deletions

22
lib/memex/notes/note.ex Normal file
View File

@ -0,0 +1,22 @@
defmodule Memex.Notes.Note do
use Ecto.Schema
import Ecto.Changeset
@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
schema "notes" do
field :content, :string
field :tag, {:array, :string}
field :title, :string
field :visibility, Ecto.Enum, values: [:public, :private, :unlisted]
timestamps()
end
@doc false
def changeset(note, attrs) do
note
|> cast(attrs, [:title, :content, :tag, :visibility])
|> validate_required([:title, :content, :tag, :visibility])
end
end