mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-21 05:53:18 +12:00
37cc01957d
* WIP * chore: fix mix.lock merge issues * improvement: upgrade to 3.0 * chore: remove `repo.to_tenant` * chore: continue removal of unnecessary helper * chore: use `Ash.ToTenant`
41 lines
742 B
Elixir
41 lines
742 B
Elixir
defmodule AshPostgres.Test.Account do
|
|
@moduledoc false
|
|
use Ash.Resource,
|
|
domain: AshPostgres.Test.Domain,
|
|
data_layer: AshPostgres.DataLayer
|
|
|
|
actions do
|
|
default_accept(:*)
|
|
|
|
defaults([:create, :read, :update, :destroy])
|
|
end
|
|
|
|
aggregates do
|
|
first(:user_is_active, :user, :is_active)
|
|
end
|
|
|
|
attributes do
|
|
uuid_primary_key(:id)
|
|
attribute(:is_active, :boolean, public?: true)
|
|
end
|
|
|
|
calculations do
|
|
calculate(
|
|
:active,
|
|
:boolean,
|
|
expr(is_active && user_is_active),
|
|
load: [:user_is_active]
|
|
)
|
|
end
|
|
|
|
postgres do
|
|
table "accounts"
|
|
repo(AshPostgres.TestRepo)
|
|
end
|
|
|
|
relationships do
|
|
belongs_to(:user, AshPostgres.Test.User) do
|
|
public?(true)
|
|
end
|
|
end
|
|
end
|