Oihana PHP Arango

aqlFieldArray.php

Table of Contents

Functions

aqlFieldArray()  : string
Generates an AQL key/value expression for counting elements in an array field.

Functions

aqlFieldArray()

Generates an AQL key/value expression for counting elements in an array field.

aqlFieldArray(string $key[, string $docRef = AQL::DOC ][, string|null $default = '[]' ]) : 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:

aqlFieldArrayCount('tags');
// Produces: "tags: IS_ARRAY(doc.tags) ? doc.tags : null"

// Count elements in a custom document variable "u" with property "authors"
aqlFieldArrayCount('authors', 'edge', '[]');
// Produces: "authors: IS_ARRAY(edge.authors) ? LENGTH(edge.authors) : []"
Parameters
$key : string

Logical key to use in the resulting AQL object.

$docRef : string = AQL::DOC

Document variable reference (default: AQL::DOC).

$default : string|null = '[]'

The default value if the doc property is not an array (Default '[]').

Tags
author

Marc Alcaraz

since
1.0.0
Return values
string

AQL key/value snippet returns an array element.

On this page

Search results