2024-01-31 07:17:40 +13:00
|
|
|
defmodule AshPostgres.Test.Subquery.Through do
|
|
|
|
@moduledoc false
|
|
|
|
alias AshPostgres.Test.Subquery.Child
|
|
|
|
alias AshPostgres.Test.Subquery.Parent
|
2024-03-28 09:52:28 +13:00
|
|
|
alias AshPostgres.Test.Subquery.ParentDomain
|
2024-01-31 07:17:40 +13:00
|
|
|
|
|
|
|
use Ash.Resource,
|
2024-03-28 09:52:28 +13:00
|
|
|
domain: AshPostgres.Test.Subquery.ChildDomain,
|
2024-01-31 07:17:40 +13:00
|
|
|
data_layer: AshPostgres.DataLayer,
|
|
|
|
authorizers: [
|
|
|
|
Ash.Policy.Authorizer
|
|
|
|
]
|
|
|
|
|
|
|
|
postgres do
|
|
|
|
repo AshPostgres.TestRepo
|
|
|
|
table "subquery_through"
|
|
|
|
end
|
|
|
|
|
|
|
|
attributes do
|
|
|
|
attribute :parent_id, :uuid do
|
2024-03-28 09:52:28 +13:00
|
|
|
public?(true)
|
2024-01-31 07:17:40 +13:00
|
|
|
primary_key?(true)
|
|
|
|
allow_nil?(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
attribute :child_id, :uuid do
|
2024-03-28 09:52:28 +13:00
|
|
|
public?(true)
|
2024-01-31 07:17:40 +13:00
|
|
|
primary_key?(true)
|
|
|
|
allow_nil?(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
code_interface do
|
|
|
|
define(:create)
|
|
|
|
define(:read)
|
|
|
|
end
|
|
|
|
|
|
|
|
relationships do
|
|
|
|
belongs_to :parent, Parent do
|
2024-03-28 09:52:28 +13:00
|
|
|
public?(true)
|
|
|
|
domain(ParentDomain)
|
2024-01-31 07:17:40 +13:00
|
|
|
end
|
|
|
|
|
|
|
|
belongs_to :child, Child do
|
2024-03-28 09:52:28 +13:00
|
|
|
public?(true)
|
2024-01-31 07:17:40 +13:00
|
|
|
source_attribute(:parent_id)
|
|
|
|
destination_attribute(:id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
policies do
|
|
|
|
policy always() do
|
|
|
|
authorize_if(always())
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
actions do
|
2024-03-28 09:52:28 +13:00
|
|
|
default_accept(:*)
|
|
|
|
|
2024-01-31 07:17:40 +13:00
|
|
|
defaults([:create, :read, :update, :destroy])
|
|
|
|
end
|
|
|
|
end
|