ash_postgres/test/support/resources/entity.ex

30 lines
551 B
Elixir
Raw Normal View History

defmodule AshPostgres.Test.Entity do
@moduledoc false
use Ash.Resource,
data_layer: AshPostgres.DataLayer
attributes do
2024-01-11 02:34:23 +13:00
uuid_primary_key(:id)
2024-01-11 02:34:23 +13:00
attribute(:full_name, :string, allow_nil?: false)
timestamps(private?: false)
end
postgres do
table "entities"
repo AshPostgres.TestRepo
end
actions do
2024-01-11 02:34:23 +13:00
defaults([:create, :read])
read :read_from_temp do
2024-01-11 02:34:23 +13:00
prepare(fn query, _ ->
Ash.Query.set_context(query, %{data_layer: %{table: "temp_entities", schema: "temp"}})
2024-01-11 02:34:23 +13:00
end)
end
end
end