Oihana PHP Arango

aqlFieldMap.php

Table of Contents

Functions

aqlFieldMap()  : string
Generates an AQL expression for mapping an array field to structured documents.

Functions

aqlFieldMap()

Generates an AQL expression for mapping an array field to structured documents.

aqlFieldMap(string $key, string $doc, array<string|int, mixed> $options[, ContainerInterface|null $container = null ][, array<string|int, mixed> $init = [] ]) : string

This method creates a sub-query that iterates over an array in the document and returns each element with only the specified fields.

Example output:

addresses: ( FOR item IN doc.addresses RETURN { street: item.street, city: item.city } )

With a Field::WHERE condition, a FILTER restricts the projected elements:

addresses: ( FOR item IN doc.addresses
             FILTER item.region IN @allowedRegions
             RETURN { street: item.street, city: item.city } )
Parameters
$key : string

The field key in the parent document (e.g., "addresses").

$doc : string

The document reference for AQL (e.g., "doc").

$options : array<string|int, mixed>

Field options:

  • Field::FIELDS: Array of sub-field definitions to include in each mapped item
  • Field::NAME: Optional source field name (defaults to $key)
  • Field::WHERE: Optional condition (Field::WHEN grammar) restricting the projected elements; its value may be an AqlBindReference (aqlBindRef).
$container : ContainerInterface|null = null

The optional DI Container reference.

$init : array<string|int, mixed> = []

The optional associative array definition.

Tags
throws
ContainerExceptionInterface
NotFoundExceptionInterface
ReflectionException
UnsupportedOperationException
BindException
ConstantException
ValidationException

If a Field::WHERE condition attribute name is unsafe.

since
1.0.0
author

Marc Alcaraz

Return values
string

AQL snippet with the array mapping expression.

On this page

Search results