Oihana PHP Arango

InsertOptions extends QueryOptions

Table of Contents

Constants

CACHE_ENABLED  : string = 'cacheEnabled'
DEDUPLICATE  : string = 'deduplicate'
DISABLE_INDEX  : string = 'disableIndex'
ESTIMATES  : string = 'estimates'
EXCLUSIVE  : string = 'exclusive'
EXPIRE_AFTER  : string = 'expireAfter'
FIELD_VALUE_TYPES  : string = 'fieldValueTypes'
FIELDS  : string = 'fields'
FORCE_INDEX_HINT  : string = 'forceIndexHint'
GEO_JSON  : string = 'geoJson'
IGNORE_ERRORS  : string = 'ignoreErrors'
IGNORE_REVS  : string = 'ignoreRevs'
IN_BACKGROUND  : string = 'inBackground'
INDEX_HINT  : string = 'indexHint'
KEEP_NULL  : string = 'keepNull'
LEGACY_POLYGONS  : string = 'legacyPolygons'
LOOKAHEAD  : string = 'lookahead'
MAX_PROJECTIONS  : string = 'maxProjections'
MERGE_OBJECTS  : string = 'mergeObjects'
METHOD  : string = 'method'
NAME  : string = 'name'
OVERWRITE_MODE  : string = 'overwriteMode'
PARALLELISM  : string = 'parallelism'
PARAMS  : string = 'params'
PREFIX_FIELDS  : string = 'prefixFields'
READ_OWN_WRITES  : string = 'readOwnWrites'
REFILL_INDEX_CACHES  : string = 'refillIndexCaches'
SPARSE  : string = 'sparse'
STORED_VALUE  : string = 'storedValue'
TYPE  : string = 'type'
UNIQUE  : string = 'unique'
USE_CACHE  : string = 'useCache'
WAIT_FOR_SYNC  : string = 'waitForSync'

Properties

$exclusive  : bool
The RocksDB engine does not require collection-level locks. Different write operations on the same collection do not block each other, as long as there are no write-write conflicts on the same documents.
$ignoreErrors  : bool
Suppress query errors that may occur when trying to update non-existing documents or when violating unique key constraints.
$overwriteMode  : string|null
To further control the behavior of INSERT on primary index unique constraint violations, there is the overwriteMode option. It offers the following modes:
$refillIndexCaches  : bool
Whether to add new entries to in-memory index caches if document insertions affect the edge index or cache-enabled persistent indexes.
$versionAttribute  : string|null
Only applicable if overwrite is set to true or overwriteMode is set to update or replace.
$waitForSync  : bool
To make sure data are durable when an update query returns.

Methods

__construct()  : mixed
Creates a new QueryOptions instance.
jsonSerialize()  : array<string|int, mixed>
Invoked to serialize the object with the json serializer.

Constants

Properties

$exclusive

The RocksDB engine does not require collection-level locks. Different write operations on the same collection do not block each other, as long as there are no write-write conflicts on the same documents.

public bool $exclusive

From an application development perspective it can be desired to have exclusive write access on collections, to simplify the development. Note that writes do not block reads in RocksDB. Exclusive access can also speed up modification queries, because we avoid conflict checks.

Tags
see
https://docs.arangodb.com/stable/aql/high-level-operations/insert/#exclusive

$overwriteMode

To further control the behavior of INSERT on primary index unique constraint violations, there is the overwriteMode option. It offers the following modes:

public string|null $overwriteMode
  • "ignore": if a document with the specified _key value exists already, nothing will be done and no write operation will be carried out. The insert operation will return success in this case. This mode does not support returning the old document version. Using RETURN OLD will trigger a parse error, as there will be no old version to return. RETURN NEW will only return the document in case it was inserted. In case the document already existed, RETURN NEW will return null.
  • "replace": if a document with the specified _key value exists already, it will be overwritten with the specified document value. This mode will also be used when no overwrite mode is specified but the overwrite flag is set to true.
  • "update": if a document with the specified _key value exists already, it will be patched (partially updated) with the specified document value.
  • "conflict": if a document with the specified _key value exists already, return a unique constraint violation error so that the insert operation fails. This is also the default behavior in case the overwrite mode is not set, and the overwrite flag is false or not set either.

The main use case of inserting documents with overwrite mode ignore is to make sure that certain documents exist in the cheapest possible way. In case the target document already exists, the ignore mode is most efficient, as it will not retrieve the existing document from storage and not write any updates to it.

When using the update overwrite mode, the keepNull and mergeObjects options control how the update is done. See UPDATE operation. FOR i IN 1..1000 INSERT { _key: CONCAT('test', i), name: "test", foobar: true } INTO users OPTIONS { overwriteMode: "update", keepNull: true, mergeObjects: false }

Tags
see
https://docs.arangodb.com/stable/aql/high-level-operations/insert/#overwritemode
Hooks
public string|null get public set
Parameters
$value : string|null

$versionAttribute

Only applicable if overwrite is set to true or overwriteMode is set to update or replace.

public string|null $versionAttribute

You can use the versionAttribute option for external versioning support. If set, the attribute with the name specified by the option is looked up in the stored document and the attribute value is compared numerically to the value of the versioning attribute in the supplied document that is supposed to update/replace it.

If the version number in the new document is higher (rounded down to a whole number) than in the document that already exists in the database, then the update/replace operation is performed normally. This is also the case if the new versioning attribute has a non-numeric value, if it is a negative number, or if the attribute doesn’t exist in the supplied or stored document.

If the version number in the new document is lower or equal to what exists in the database, the operation is not performed and the existing document thus not changed. No error is returned in this case. The attribute can only be a top-level attribute.

For example, the following query conditionally replaces an existing document with the key "123" if the attribute externalVersion currently has a value below 5: INSERT { _key: "123", externalVersion: 5, anotherAttribute: true } IN coll OPTIONS { overwriteMode: "replace", versionAttribute: "externalVersion" }

You can check if OLD._rev (if not null) and NEW._rev are different to determine if the document has been changed.

Tags
see
https://docs.arangodb.com/stable/aql/high-level-operations/insert/#versionattribute

Methods

__construct()

Creates a new QueryOptions instance.

public __construct([array<string|int, mixed>|object|null $init = null ]) : mixed
Parameters
$init : array<string|int, mixed>|object|null = null

A generic object containing properties with which to populate the newly instance. If this argument is null, it is ignored.

jsonSerialize()

Invoked to serialize the object with the json serializer.

public jsonSerialize() : array<string|int, mixed>
Tags
throws
ReflectionException
Return values
array<string|int, mixed>
On this page

Search results