Oihana PHP Arango

value.php

Table of Contents

Functions

value()  : string
Extract a value from a document at the specified path.

Functions

value()

Extract a value from a document at the specified path.

value(string $document, array<string|int, mixed> $path) : string

This helper wraps the ArangoDB AQL function VALUE(document, path) which extracts a value from a document using a path array. The path can contain strings (object keys) and integers (array indices) to navigate through nested structures.

Example AQL usage:

VALUE(doc, ["author", "name"])        // extracts doc.author.name
VALUE(doc, ["tags", 0])               // extracts first element of doc.tags array
VALUE(doc, ["metadata", "version"])   // extracts doc.metadata.version
Parameters
$document : string

The document variable or expression to extract value from.

$path : array<string|int, mixed>

An array of strings and numbers describing the attribute path. Use strings for object keys and integers for array indices.

Tags
example
use function oihana\arango\db\functions\documents\value;

$expr = value('doc', ['author', 'name']);
// Produces: 'VALUE(doc, ["author","name"])'

$expr = value('doc', ['tags', 0]);
// Produces: 'VALUE(doc, ["tags",0])'
see
https://docs.arangodb.com/stable/aql/functions/document-object/#value
since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results