Files
Claper/lib/claper/posts/reaction.ex
2022-07-23 01:44:03 +02:00

22 lines
462 B
Elixir

defmodule Claper.Posts.Reaction do
use Ecto.Schema
import Ecto.Changeset
schema "reactions" do
field :icon, :string
field :attendee_identifier, :string
belongs_to :post, Claper.Posts.Post
belongs_to :user, Claper.Accounts.User
timestamps()
end
@doc false
def changeset(reaction, attrs) do
reaction
|> cast(attrs, [:icon, :attendee_identifier, :user_id, :post_id])
|> validate_required([:icon, :post_id])
end
end