DocumentsUpsertTrait uses trait:short
Table of Contents
Methods
- buildUpsertQuery() : string
- Build the AQL query for an upsert clause (upsert or repsert modes).
- upsert() : array<string, mixed>|object|null
- Upsert a document into the collection (update or insert).
Methods
buildUpsertQuery()
Build the AQL query for an upsert clause (upsert or repsert modes).
public
buildUpsertQuery("update"|"replace" $mode[, array<string|int, mixed> $init = [] ][, array<string|int, mixed> &$bindVars = [] ]) : string
Parameters
- $mode : "update"|"replace"
-
Operation mode: 'update' for upsert, 'replace' for repsert.
- $init : array<string|int, mixed> = []
-
The initialization array with optional settings:
- value (mixed) : The value to search for.
- key (?string) : The attribute key to target (default "_key").
- prefix (?string) : Document prefix (default "doc").
- binds : Bind variables array.
- conditions : Extra conditions for the AQL FILTER.
- extraQuery : Extra AQL snippets to inject in the FILTER.
- active : Optional active flag.
- fields (?array) : Specific fields to return.
- skin (?string) : Skin to apply on the result document.
- $bindVars : array<string|int, mixed> = []
-
The bind variables reference.
Tags
Return values
string —The AQL query expression.
upsert()
Upsert a document into the collection (update or insert).
public
upsert([array<string, mixed> $init = [] ]) : array<string, mixed>|object|null
Parameters
- $init : array<string, mixed> = []
-
The optional parameters to passed-in the function.
Detail of the options :
- binds : The binding variables to use in the aql connector.
- collection : The name of the collection or use the collection property of the model.
- filter : The alternative filterExpression, this syntax for UPSERT operations allows you to use more flexible filter conditions beyond equality matches to look up documents.
- search : The 'searchExpression' contains the document to be looked for. It must be an object literal (UPSERT {
: , ... } ...) without dynamic attribute names. In case no such document can be found in collection, a new document is inserted into the collection as specified in the insertExpression. - insert : The document to insert in the collection if the document not exist.
- update : The document to update or replace in the collection.
- overwrite : The overwriting mode "REPLACE" or "UPDATE" (default)
- options : The optional upsert options definition array or object.