aqlFieldArrayCount.php
Table of Contents
Functions
- aqlFieldArrayCount() : string
- Generates an AQL key/value expression for counting elements in an array field.
Functions
aqlFieldArrayCount()
Generates an AQL key/value expression for counting elements in an array field.
aqlFieldArrayCount(string $key[, string $docRef = AQL::DOC ][, string|null $alias = null ]) : string
This helper constructs an expression suitable for inclusion in a RETURN { ... } block.
It safely checks if the field is an array using IS_ARRAY() and returns its length
with LENGTH(). If the field is not an array, it defaults to 0.
Example usage:
// Count elements in "tags" array in "doc"
aqlFieldArrayCount('tagCount');
// Produces: "tagCount: IS_ARRAY(doc.tags) ? LENGTH(doc.tags) : 0"
// Count elements in a custom document variable "u" with property "authors"
aqlFieldArrayCount('authorCount', 'u', 'authors');
// Produces: "authorCount: IS_ARRAY(u.authors) ? LENGTH(u.authors) : 0"
Parameters
- $key : string
-
Logical key to use in the resulting AQL object.
- $docRef : string = AQL::DOC
-
Document variable reference (default:
AQL::DOC). - $alias : string|null = null
-
Optional alias or property name in the document if different from
$key.
Tags
Return values
string —AQL key/value snippet counting array elements.