mergeWrittenPayload.php
Table of Contents
Functions
- mergeWrittenPayload() : array<string, mixed>
- Merges the optional `new` / `old` payload returned by an ArangoDB write endpoint into the meta document, so the caller sees a single flat array regardless of whether `returnNew` / `returnOld` was set.
Functions
mergeWrittenPayload()
Merges the optional `new` / `old` payload returned by an ArangoDB write endpoint into the meta document, so the caller sees a single flat array regardless of whether `returnNew` / `returnOld` was set.
mergeWrittenPayload(array<string, mixed> $body, string $payloadField) : array<string, mixed>
On an insert / update / replace call with returnNew: true, the
server responds with:
{ "_key" : "..." , "_id" : "..." , "_rev" : "..." , "new" : { ... full document ... } }
The wire convention is that the meta attributes (_key / _id /
_rev, and for edges _from / _to) take precedence over the
payload — even when _rev is duplicated in both, the outer copy
is the authoritative one. This helper applies that precedence and
strips the now-redundant payload field from the result.
When the payload field is absent (the caller did not request
returnNew / returnOld), $body is returned untouched.
Pure function — used by Collection write paths and by the gharial vertex/edge write paths.
Parameters
- $body : array<string, mixed>
-
Full response body carrying the meta attributes at the top level and (optionally) the payload under
$payloadField. - $payloadField : string
-
Name of the optional payload field (
newon insert/update/replace,oldon remove).
Return values
array<string, mixed> —The meta merged with the payload (meta wins on key collisions), with the payload field stripped. When the payload is absent, $body is returned unchanged.