op: for_each
Iterate a collection and run ops for each element.
Allowed phases
| Phase | Status |
|---|---|
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
| Field | Required | Description |
|---|---|---|
for_each | yes | Expression evaluating to an array |
then | yes | Ops per iteration |
Behavior
- Iterator variable is
iteminfor_each(andemit_each). - Use
continueto skip to the next iteration;stopto halt the rule.
Related operations
if · stop · continue · emit_each
See also
- Operations index — all ops by phase
- actions — rule structure and phases
- Intents: Rules — narrative examples