Oihana PHP Arango

arrayMap.php

Table of Contents

Functions

arrayMap()  : string
Build an AQL array inline projection `array[* RETURN <expression>]`.

Functions

arrayMap()

Build an AQL array inline projection `array[* RETURN <expression>]`.

arrayMap(string $array, string $expression) : string

This is AQL's array expansion in its projecting form: it maps each element of $array to $expression (which typically references the loop variable Clause::CURRENT), yielding a new array. It is the read-only sibling of arrayFilter() ([* FILTER cond]).

$expression is interpolated verbatim — callers are responsible for building it from trusted/whitelisted pieces (e.g. CURRENT, an alterExpression() chain, or a validated sub-field). pluck() is the safe specialization for a single sub-field (it validates the field name first).

Parameters
$array : string

The array expression to expand (e.g. doc.tags, @value).

$expression : string

The expression returned for each element (e.g. LOWER(CURRENT)).

Tags
example
use function oihana\arango\db\functions\arrays\arrayMap;

echo arrayMap( 'doc.tags' , 'LOWER(CURRENT)' );        // doc.tags[* RETURN LOWER(CURRENT)]
echo arrayMap( '@value'   , 'LOWER(CURRENT)' );        // @value[* RETURN LOWER(CURRENT)]
echo arrayMap( 'doc.items', 'CURRENT.price' );         // doc.items[* RETURN CURRENT.price]
see
arrayFilter()

For the filtering form [* FILTER cond].

pluck()

For the safe single-sub-field projection.

https://docs.arangodb.com/stable/aql/operators/#array-expansion
since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL inline projection.

On this page

Search results