ash_postgres/test/support/resources/post.ex
Zach Daniel 7f8aa98f24 improvement: better errors for multitenant unique constraints
fix: un-break the `in` filter type casting code

test: add tests for untested features
2021-01-26 15:07:26 -05:00

39 lines
793 B
Elixir

defmodule AshPostgres.Test.Post do
@moduledoc false
use Ash.Resource,
data_layer: AshPostgres.DataLayer
postgres do
table "posts"
repo AshPostgres.TestRepo
end
actions do
read(:read)
create(:create)
end
attributes do
uuid_primary_key(:id, writable?: true)
attribute(:title, :string)
attribute(:score, :integer)
attribute(:public, :boolean)
attribute(:category, :ci_string)
end
relationships do
has_many(:comments, AshPostgres.Test.Comment, destination_field: :post_id)
end
aggregates do
count(:count_of_comments, :comments)
count :count_of_comments_called_match, :comments do
filter(title: "match")
end
first :first_comment, :comments, :title do
sort(title: :asc_nils_last)
end
end
end