ash_phoenix/test/support/resources/comment.ex
Zach Daniel d7ec7da419
improvement: refactor forms with new data structure AshPhoenix.Form (#6)
Co-authored-by: Darren Black <dblack@totaltrash.net>
2021-07-15 14:09:15 -04:00

36 lines
730 B
Elixir

defmodule AshPhoenix.Test.Comment do
@moduledoc false
use Ash.Resource, data_layer: Ash.DataLayer.Ets
ets do
private?(true)
end
actions do
read(:read, primary?: true)
read :featured do
filter(expr(featured == true))
end
create :create do
argument(:post, :map)
change(manage_relationship(:post, type: :direct_control))
end
update :update do
argument(:post, :map)
change(manage_relationship(:post, type: :direct_control))
end
end
attributes do
uuid_primary_key(:id)
attribute(:featured, :boolean, default: false)
attribute(:text, :string, allow_nil?: false)
end
relationships do
belongs_to(:post, AshPhoenix.Test.Post)
end
end