mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-21 05:53:18 +12:00
27 lines
550 B
Elixir
27 lines
550 B
Elixir
defmodule AshPostgres.Test.Rating do
|
|
@moduledoc false
|
|
use Ash.Resource,
|
|
domain: AshPostgres.Test.Domain,
|
|
data_layer: AshPostgres.DataLayer
|
|
|
|
postgres do
|
|
polymorphic?(true)
|
|
repo AshPostgres.TestRepo
|
|
end
|
|
|
|
actions do
|
|
default_accept(:*)
|
|
|
|
defaults([:create, :read, :update, :destroy])
|
|
end
|
|
|
|
attributes do
|
|
uuid_primary_key(:id)
|
|
attribute(:score, :integer, public?: true)
|
|
attribute(:resource_id, :uuid, public?: true)
|
|
end
|
|
|
|
calculations do
|
|
calculate(:double_score, :integer, expr(score * 2))
|
|
end
|
|
end
|