Reads a field directly from an AssignmentRelationship record.
Filters AssignmentRelationship by target_id = current.id and returns the named
field from each matching record — no second hop to the source instance. This is the
right choice when you want a value that lives on the relationship itself (:value,
:thing, :pool, :alias) rather than on the assigning instance.
Use FieldViaAssignedRelationship instead when you need a field from the source
instance (e.g. :name).
Options
field:(required) — atom naming the field to read from the relationship record (e.g.:value,:thing,:pool,:alias).alias:(optional) — atom matching thealiasattribute on the relationship. When omitted, all assignments wheretarget_id = current.idare included.
Examples
# Port number assigned to this service under the :primary slot
calculate :assigned_port, {:array, :integer},
{Diffo.Provider.Calculations.FieldFromAssignment, [alias: :primary, field: :value]}
# Pool name for every assignment on this instance
calculate :assignment_pools, {:array, :atom},
{Diffo.Provider.Calculations.FieldFromAssignment, [field: :pool]}
Summary
Functions
Callback implementation for Ash.Resource.Calculation.describe/1.
Callback implementation for Ash.Resource.Calculation.has_expression?/0.
Callback implementation for Ash.Resource.Calculation.init/1.
Callback implementation for Ash.Resource.Calculation.strict_loads?/0.
Functions
Callback implementation for Ash.Resource.Calculation.describe/1.
Callback implementation for Ash.Resource.Calculation.has_expression?/0.
Callback implementation for Ash.Resource.Calculation.init/1.
Callback implementation for Ash.Resource.Calculation.strict_loads?/0.