op: find
Bind the first matching array element to a variable.
Allowed phases
| Phase | Status |
|---|---|
preflight | ✓ allowed |
core | ✓ allowed |
side_effects | ✗ forbidden |
Syntax
- op: find
path: /cart/items
where: "it.product_id == event.product_id"
as: existing_item
- op: if
expr: "existing_item != null"
then:
- op: merge
path: existing_item
value:
quantity: "existing_item.quantity + event.quantity"Parameters
| Field | Required | Description |
|---|---|---|
path | yes | Array field path |
where | yes | Plain string; it = current element |
as | yes | Variable name (null if no match) |
Behavior
- In preflight, use for duplicate detection before
reject. - In core, pair with
mergeorif/else+pushfor upsert-into-array patterns. whereis a plain string, not{ expr: ... }.
Related operations
See also
- Operations index — all ops by phase
- actions — rule structure and phases
- Intents: Rules — narrative examples