mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 21:43:12 +12:00
35 lines
686 B
Elixir
35 lines
686 B
Elixir
defmodule AshPostgres.Test.User do
|
|
@moduledoc false
|
|
use Ash.Resource, data_layer: AshPostgres.DataLayer
|
|
|
|
actions do
|
|
defaults([:create, :read, :update, :destroy])
|
|
|
|
read :active do
|
|
filter(expr(active))
|
|
end
|
|
end
|
|
|
|
calculations do
|
|
calculate(:active, :boolean, expr(is_active == true))
|
|
end
|
|
|
|
attributes do
|
|
uuid_primary_key(:id)
|
|
attribute(:is_active, :boolean)
|
|
attribute(:name, :string)
|
|
end
|
|
|
|
postgres do
|
|
table "users"
|
|
repo(AshPostgres.TestRepo)
|
|
end
|
|
|
|
relationships do
|
|
belongs_to :organization, AshPostgres.Test.Organization do
|
|
attribute_writable?(true)
|
|
end
|
|
|
|
has_many(:accounts, AshPostgres.Test.Account)
|
|
end
|
|
end
|