25 lines
573 B
Elixir
25 lines
573 B
Elixir
defmodule Nulla.Models.Notification do
|
|
use Ecto.Schema
|
|
import Ecto.Changeset
|
|
alias Nulla.Models.User
|
|
alias Nulla.Models.Actor
|
|
|
|
@primary_key {:id, :integer, autogenerate: false}
|
|
schema "notifications" do
|
|
field :type, :string
|
|
field :data, :map
|
|
field :read, :boolean, default: false
|
|
|
|
belongs_to :user, User
|
|
belongs_to :actor, Actor
|
|
|
|
timestamps()
|
|
end
|
|
|
|
@doc false
|
|
def changeset(notification, attrs) do
|
|
notification
|
|
|> cast(attrs, [:user_id, :actor_id, :type, :data, :read])
|
|
|> validate_required([:user_id, :type])
|
|
end
|
|
end
|