spazio-solazzo/lib/spazio_solazzo/booking_system/asset.ex
2026-01-10 19:03:02 +01:00

43 lines
883 B
Elixir

defmodule SpazioSolazzo.BookingSystem.Asset do
@moduledoc """
Represents bookable assets within a space, such as rooms or equipment.
"""
use Ash.Resource,
otp_app: :spazio_solazzo,
domain: SpazioSolazzo.BookingSystem,
data_layer: AshPostgres.DataLayer
postgres do
table "assets"
repo SpazioSolazzo.Repo
end
actions do
defaults [:read, create: :*]
read :get_space_assets do
argument :space_id, :string do
allow_nil? false
end
filter expr(space_id == ^arg(:space_id))
end
end
attributes do
uuid_primary_key :id
attribute :name, :string, allow_nil?: false, public?: true
end
relationships do
belongs_to :space, SpazioSolazzo.BookingSystem.Space do
allow_nil? false
public? true
end
end
identities do
identity :unique_name_per_space, [:name, :space_id]
end
end