mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 21:43:12 +12:00
fb8a13f33d
improvement: use `prepend?: true` option when applying relationship sorts
30 lines
609 B
Elixir
30 lines
609 B
Elixir
defmodule AshPostgres.Test.PostLink do
|
|
@moduledoc false
|
|
use Ash.Resource,
|
|
data_layer: AshPostgres.DataLayer
|
|
|
|
postgres do
|
|
table "post_links"
|
|
repo AshPostgres.TestRepo
|
|
end
|
|
|
|
actions do
|
|
defaults([:create, :read, :update, :destroy])
|
|
end
|
|
|
|
identities do
|
|
identity(:unique_link, [:source_post_id, :destination_post_id])
|
|
end
|
|
|
|
relationships do
|
|
belongs_to :source_post, AshPostgres.Test.Post do
|
|
allow_nil?(false)
|
|
primary_key?(true)
|
|
end
|
|
|
|
belongs_to :destination_post, AshPostgres.Test.Post do
|
|
allow_nil?(false)
|
|
primary_key?(true)
|
|
end
|
|
end
|
|
end
|