ash_cubdb/test/support/post.ex

36 lines
731 B
Elixir
Raw Normal View History

2023-08-07 17:47:06 +12:00
defmodule Support.Post do
@moduledoc false
2024-03-28 10:27:46 +13:00
use Ash.Resource, data_layer: AshCubDB.DataLayer, domain: Support.Domain
2023-08-07 17:47:06 +12:00
cubdb do
otp_app :ash_cubdb
end
attributes do
2024-03-28 10:27:46 +13:00
uuid_primary_key :id, writable?: true, public?: true
attribute :title, :string, public?: true
attribute :body, :string, public?: true
2023-08-07 17:47:06 +12:00
end
actions do
2024-03-28 10:27:46 +13:00
default_accept [:id, :title, :body]
2023-10-02 15:36:56 +13:00
defaults ~w[create read update destroy]a
2023-08-07 17:47:06 +12:00
end
calculations do
calculate :all_text, :string, expr(title <> body)
end
2023-08-07 17:47:06 +12:00
relationships do
belongs_to :author, Support.Author
2023-08-07 17:47:06 +12:00
end
code_interface do
define :create
define :read
define :update
define :get, action: :read, get_by: [:id]
2023-10-02 15:36:56 +13:00
define :destroy
2023-08-07 17:47:06 +12:00
end
end