Diffo.Provider.Calculations.FieldViaAssignedRelationship (Diffo v0.4.1)

Copy Markdown View Source

Reads a field from the source instance of an AssignmentRelationship.

Traverses AssignmentRelationship in reverse — filtering by target_id = current.id — to reach the source instances (pool owners) that assigned something to this instance, then returns the named field from each.

Options

  • field: (required) — atom naming the field to read from the source instance (e.g. :name, :type).
  • via: (optional) — list of alias atoms to step through. Each step filters AssignmentRelationship by the alias and follows source_id to the next set of instances. Multi-hop is supported by chaining steps. When omitted, all assignments where target_id = current.id are traversed without alias filtering.

Examples

# Name of the CVC that holds the :svlan assignment slot on this AVC
calculate :cvc_id, {:array, :string},
  {Diffo.Provider.Calculations.FieldViaAssignedRelationship, [via: [:svlan], field: :name]}

# Name of every instance that has ever assigned anything to this one
calculate :assigner_names, {:array, :string},
  {Diffo.Provider.Calculations.FieldViaAssignedRelationship, [field: :name]}

Summary

Functions

describe(opts)

Callback implementation for Ash.Resource.Calculation.describe/1.

has_calculate?()

has_expression?()

Callback implementation for Ash.Resource.Calculation.has_expression?/0.

init(opts)

Callback implementation for Ash.Resource.Calculation.init/1.

strict_loads?()

Callback implementation for Ash.Resource.Calculation.strict_loads?/0.