aqlFieldArrayFirst.php
Table of Contents
Functions
- aqlFieldArrayFirst() : string
- Generates an AQL key/value expression for extracting the first element of an array field.
Functions
aqlFieldArrayFirst()
Generates an AQL key/value expression for extracting the first element of an array field.
aqlFieldArrayFirst(string $key, string $value) : string
This helper constructs an expression suitable for inclusion in a RETURN { ... } block.
It checks if the field is an array using IS_ARRAY() and returns the first element
using FIRST(). If the field is not an array, it returns null.
Example usage:
// Extract the first author from "doc.authors"
aqlFieldArrayFirst('mainAuthor', 'doc.authors');
// Produces: "mainAuthor: IS_ARRAY(doc.authors) ? FIRST(doc.authors) : null"
// Extract the first tag from a custom variable
aqlFieldArrayFirst('firstTag', 'tagsList');
// Produces: "firstTag: IS_ARRAY(tagsList) ? FIRST(tagsList) : null"
Parameters
- $key : string
-
Logical key to use in the resulting AQL object.
- $value : string
-
AQL field reference to evaluate (e.g.
'doc.authors').
Tags
Return values
string —AQL key/value snippet extracting the first array element.