use Ash.Resource, data_layer: AshPostgres.DataLayer
# ...
calculations do
calculate(
:end_time,
:utc_datetime,
expr(datetime_add(start_time, duration, :minute))
)
end
attributes do
uuid_primary_key(:id)
attribute :start_time, :utc_datetime do
allow_nil?(false)
end
attribute :duration, :integer do
default(30)
end
attribute(:description, :string)
timestamps()
end
use Ash.Resource, data_layer: AshPostgres.DataLayer
# ...
calculations do
calculate(
:end_time,
:utc_datetime,
expr(datetime_add(start_time, duration, :minute))
)
end
attributes do
uuid_primary_key(:id)
attribute :start_time, :utc_datetime do
allow_nil?(false)
end
attribute :duration, :integer do
default(30)
end
attribute(:description, :string)
timestamps()
end