arrayFilter.php
Table of Contents
Functions
- arrayFilter() : string
- Build an AQL array inline filter `array[* FILTER <condition>]`.
Functions
arrayFilter()
Build an AQL array inline filter `array[* FILTER <condition>]`.
arrayFilter(string $array, string $condition) : string
This is AQL's array expansion in its filtering form: it keeps the elements of
$array for which $condition (which typically references the loop variable
Clause::CURRENT) holds, yielding a sub-array. It
is the filtering sibling of arrayMap() ([* RETURN expr]).
Combined with length() it expresses an existential test —
LENGTH(doc.items[* FILTER CURRENT.active]) > 0 — though the boolean array
"question mark" operator ([? FILTER …], see arrayContains()) is a more
direct way to write the same intent.
$condition is interpolated verbatim — callers are responsible for building it
from trusted/whitelisted pieces (bound values, validated fields, …).
Parameters
- $array : string
-
The array expression to expand (e.g.
doc.contactPoint). - $condition : string
-
The FILTER condition tested on each element (e.g.
CURRENT.email != null).
Tags
Return values
string —The formatted AQL inline filter.