Oihana PHP Arango

merge.php

Table of Contents

Functions

merge()  : string
Merge multiple documents into a single document.

Functions

merge()

Merge multiple documents into a single document.

merge(string|array<string|int, mixed>|null $documents) : string

This helper wraps the ArangoDB AQL function MERGE(document1, document2, ... documentN) which merges multiple documents into a single document. Later documents override attributes from earlier documents if they have the same key.

Example AQL usage:

MERGE(doc1, doc2)             // merges doc1 and doc2
MERGE(doc1, doc2, doc3)       // merges three documents
MERGE({a: 1}, {b: 2})         // returns {a: 1, b: 2}
MERGE({a: 1}, {a: 2})         // returns {a: 2} (later overrides)
Parameters
$documents : string|array<string|int, mixed>|null

Multiple documents to merge (at least 2 required).

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

$expr = merge(['doc1', 'doc2']);
// Produces: 'MERGE(doc1, doc2)'

$expr = merge('doc1, doc2, doc3');
// Produces: 'MERGE(doc1, doc2, doc3)'
see
https://docs.arangodb.com/stable/aql/functions/document-object/#merge
since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results