op: for_each

Iterate a collection and run ops for each element.

Allowed phases

PhaseStatus
preflight✓ allowed
core✓ allowed
side_effects✓ allowed

Syntax

- op: for_each
  for_each: "entity.notifications ?: []"
  then:
    - op: emit
      event_type: NOTIFICATION_SENT
      payload:
        user_id:         event.user_id
        notification_id: "item.id"

Parameters

FieldRequiredDescription
for_eachyesExpression evaluating to an array
thenyesOps per iteration

Behavior

  • Iterator variable is item in for_each (and emit_each).
  • Use continue to skip to the next iteration; stop to halt the rule.

if · stop · continue · emit_each

See also