op: find

Bind the first matching array element to a variable.

Allowed phases

PhaseStatus
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

FieldRequiredDescription
pathyesArray field path
whereyesPlain string; it = current element
asyesVariable name (null if no match)

Behavior

  • In preflight, use for duplicate detection before reject.
  • In core, pair with merge or if/else + push for upsert-into-array patterns.
  • where is a plain string, not { expr: ... }.

merge · reject · if

See also