DocumentsArrayTrait uses trait:short, trait:short, \oihana\models\traits\signals\HasUpdateSignals
Manage an **embedded array field** of an ArangoDB document — add, remove, move, test membership — server-side, atomically, in a single AQL `UPDATE`.
This replaces the legacy ListItemTrait / MultiFieldTrait. The behaviour of a
field (ordering, uniqueness, optional length counter) is declared once on the
model through the arrays option (static::initializeArrays()), so callers
never repeat unique/counter/sorted flags:
new Documents( $container,
[
AQL::COLLECTION => 'Playlist',
AQL::ARRAYS =>
[
'tracks' => [ ArrayMode::LIST , Arango::COUNTER => 'numberOfTracks' ],
'tags' => ArrayMode::SET ,
'genres' => ArrayMode::SORTED_SET ,
],
]);
Document identification follows the model convention: Arango::OWNER is the value
that identifies the document, matched against the Arango::KEY attribute (default
_key); Arango::VALUE is the array element(s) being added/removed/moved.
All write methods emit the HasUpdateSignals beforeUpdate / afterUpdate
signals, like the other write operations of the model.
Tags
Table of Contents
Properties
- $arrays : array<string|int, mixed>
- The per-field embedded-array configuration, normalised to `[ field => [ Arango::MODE => ArrayMode::*, Arango::COUNTER => ?string ] ]`.
- $collection : string|null
- The default collection name.
- $indexes : array<string|int, mixed>|null
- The declared indexes of the collection (the `AQL::INDEXES` list of {@see IndexOptions} or raw definitions). Retained at initialization — whether the lazy provisioning ran or not — so the declaration can be compared with the server later ({@see DoctorTrait::diagnose()}).
- $arangodb : ArangoDB|null
- The ArangoDB database reference.
- $type : int
- Indicates the type of the collection when is created (document or edge).
Methods
- analyzerExists() : bool
- Checks if an analyzer exists on the server (built-in analyzers are always reported).
- arrayContains() : bool
- Checks whether the array `field` of a single document (identified by `owner`) contains `value`.
- arrayDefaults() : array<string, array<string|int, mixed>|int>
- Returns the default seed for the declared embedded array fields: each array field defaults to `[]`, and each declared counter to `0`.
- arrayInsert() : object|null
- Adds one or several values to the array `field` of a single document.
- arrayMove() : object|null
- Moves an existing `value` to the given zero-based `position` inside the array `field`.
- arrayPurgeRef() : array<string|int, object>|int
- Removes a `value` from the array `field` of **every** document of the collection that contains it — typically to purge a now-deleted reference.
- arrayRemove() : object|null
- Removes one or several values from the array `field` of a single document.
- bind() : string
- Bind a value to an AQL query variable.
- bindCollection() : string
- Bind a collection name to an AQL query variable.
- bindView() : string
- Bind the model's declared View name (`AQL::VIEW` block, {@see Search::NAME}) to an AQL query variable — collection bind parameters (`@@view`) are valid for View names as well.
- collectionCreate() : bool
- Creates a new collection if not exist.
- collectionDrop() : bool
- Drops a collection if exist.
- collectionExists() : bool
- Check if collection exists
- collectionRename() : bool
- Renames a collection if exist.
- collectionTruncate() : bool
- Truncate a collection if exist.
- createIndex() : array<string|int, mixed>|null
- Creates an index on a collection on the server.
- debugQuery() : void
- Debug the passed-in query and binds variables.
- explain() : ExplainResult
- Explains an AQL query — returns the optimizer's execution plan as a typed {@see ExplainResult} (rules applied, collections, estimated cost, indexes actually used) **without executing the query**.
- foundRows() : int
- For a SELECT with a LIMIT clause, returns the number of rows that would be returned were there no LIMIT clause.
- getDatabase() : ArangoDB
- Returns the ArangoDB database singleton reference.
- getDocuments() : array<string|int, mixed>
- Prepare, execute and returns an array of all documents with the passed-in AQL query.
- getExtra() : array<string|int, mixed>
- Returns the AQL current extra datas.
- getFirstResult() : mixed
- Prepare, execute and returns the first result of the passed-in AQL query.
- getObject() : object|null
- Prepare, execute and returns an object with the passed-in AQL query.
- getProfile() : ProfileResult
- Returns the typed profile of the last profiled query run (per-phase timings, {@see ExecutionStats}, warnings).
- getResult() : object|null
- Prepare, execute and returns an array with the passed-in AQL query.
- getStats() : ExecutionStats
- Returns the typed execution statistics of the last query (scanned / filtered / time / memory …). Most meaningful right after a profiled `list()` / `get()` (see {@see Arango::PROFILE}).
- initializeArrays() : static
- Initialize the per-field embedded-array configuration from the `arrays` option.
- initializeCollection() : static
- Sets the internal collection reference.
- initializeDatabase() : static
- Set the internal arangoDB reference.
- initializeIndexes() : static
- Sets the declared indexes of the collection from the init definition, normalizing a single {@see IndexOptions} value to a one-element list (a raw array always stays the index list) — so every consumer sees a plain `IndexOptions[]`: the {@see initializeCollection()} lazy provisioning and the {@see \oihana\arango\models\traits\DoctorTrait} diagnose/repair diffs.
- prepareAndExecute() : static
- Prepare and execute an ArangoDB AQL query.
- registerProperty() : void
- Register a specific dynamic property in the binds and values collection to generates a query.
- streamDocuments() : Generator<string|int, mixed>
- Prepare, execute and returns a generator of documents with the passed-in AQL query.
- viewCreate() : bool
- Creates an `arangosearch` View if it does not already exist.
- viewExists() : bool
- Checks if a View exists.
- arrayCounter() : string|null
- Returns the configured length-counter attribute of an array field, or null.
- arrayMode() : string
- Resolves the {@see ArrayMode} of an array field, honouring an optional per-call `mode` override, then the declared configuration, then defaulting to LIST.
- arrayWith() : string
- Builds the `WITH { ... }` object clause: the array field, its optional length counter, and the `modified` timestamp unless `touch` is disabled.
- ensureArrayDefaults() : Closure|null
- Builds an `ensure` closure that seeds the declared array fields to `[]` (and their counters to `0`) for any missing key of a document being created, then applies the optional user-supplied `ensure`. Returns the user closure unchanged when no array field is declared (so models without `AQL::ARRAYS` are untouched).
- profileOptions() : array<string|int, mixed>
- Merges the cursor `profile` option into `$options` when the `$init` array requests profiling via {@see Arango::PROFILE} (`true` → profile level 2, or an explicit integer level). Returns `$options` unchanged otherwise.
- runArrayUpdate() : object|null
- Compiles and executes a single-document array UPDATE (`FOR ... FILTER ... LET ... UPDATE ... RETURN NEW`), emitting the update signals around the write.
Properties
$arrays
The per-field embedded-array configuration, normalised to `[ field => [ Arango::MODE => ArrayMode::*, Arango::COUNTER => ?string ] ]`.
public
array<string|int, mixed>
$arrays
= []
$collection
The default collection name.
public
string|null
$collection
$indexes
The declared indexes of the collection (the `AQL::INDEXES` list of {@see IndexOptions} or raw definitions). Retained at initialization — whether the lazy provisioning ran or not — so the declaration can be compared with the server later ({@see DoctorTrait::diagnose()}).
public
array<string|int, mixed>|null
$indexes
= null
$arangodb
The ArangoDB database reference.
protected
ArangoDB|null
$arangodb
= null
$type
Indicates the type of the collection when is created (document or edge).
protected
int
$type
Methods
analyzerExists()
Checks if an analyzer exists on the server (built-in analyzers are always reported).
public
analyzerExists(string $name) : bool
Parameters
- $name : string
-
The name of the analyzer.
Return values
boolarrayContains()
Checks whether the array `field` of a single document (identified by `owner`) contains `value`.
public
arrayContains([array{owner?: mixed, field?: string, value?: mixed, key?: string, prefix?: string, debug?: bool} $init = [] ]) : bool
Generated AQL:
RETURN LENGTH( FOR doc IN @@collection FILTER doc._key == @key && POSITION(doc.field, @value) RETURN 1 ) > 0
Parameters
- $init : array{owner?: mixed, field?: string, value?: mixed, key?: string, prefix?: string, debug?: bool} = []
Tags
Return values
bool —True if the value is present.
arrayDefaults()
Returns the default seed for the declared embedded array fields: each array field defaults to `[]`, and each declared counter to `0`.
public
arrayDefaults() : array<string, array<string|int, mixed>|int>
Used to initialize a freshly created document so that every declared array field is always a real (possibly empty) array — see ensureArrayDefaults().
Return values
array<string, array<string|int, mixed>|int> —e.g. [ 'tracks' => [], 'numberOfTracks' => 0, 'tags' => [] ].
arrayInsert()
Adds one or several values to the array `field` of a single document.
public
arrayInsert([array{owner?: mixed, field?: string, value?: mixed, side?: string, mode?: string, key?: string, prefix?: string, touch?: bool, options?: array|object|string|null, debug?: bool} $init = [] ]) : object|null
The uniqueness and sorting are driven by the field's ArrayMode; value
may be a scalar or an array (its elements are appended, never nested).
Generated AQL (LIST/SET, side RIGHT):
... UPDATE doc WITH { field: APPEND(doc.field, @value [, true]) [, counter: LENGTH(...)] [, modified: ...] } ...
Parameters
- $init : array{owner?: mixed, field?: string, value?: mixed, side?: string, mode?: string, key?: string, prefix?: string, touch?: bool, options?: array|object|string|null, debug?: bool} = []
Tags
Return values
object|null —The updated document, or null if no document matched.
arrayMove()
Moves an existing `value` to the given zero-based `position` inside the array `field`.
public
arrayMove([array{owner?: mixed, field?: string, value?: mixed, position?: int, key?: string, prefix?: string, touch?: bool, options?: array|object|string|null, debug?: bool} $init = [] ]) : object|null
Unsupported on a ArrayMode::SORTED_SET field (the sort order overrides any manual position): an UnsupportedOperationException is thrown.
Generated AQL:
LET __rm = REMOVE_VALUE(doc.field, @value)
LET __arr = APPEND( PUSH( SLICE(__rm, 0, <pos>), @value, true ), SLICE(__rm, <pos>) )
UPDATE doc WITH { field: __arr [, counter: LENGTH(__arr)] [, modified: ...] } ...
Parameters
- $init : array{owner?: mixed, field?: string, value?: mixed, position?: int, key?: string, prefix?: string, touch?: bool, options?: array|object|string|null, debug?: bool} = []
Tags
Return values
object|null —The updated document, or null if no document matched.
arrayPurgeRef()
Removes a `value` from the array `field` of **every** document of the collection that contains it — typically to purge a now-deleted reference.
public
arrayPurgeRef([array{field?: string, value?: mixed, prefix?: string, touch?: bool, count?: bool, options?: array|object|string|null, debug?: bool} $init = [] ]) : array<string|int, object>|int
Generated AQL:
FOR doc IN @@collection FILTER POSITION(doc.field, @value) LET __arr = REMOVE_VALUE(doc.field, @value) UPDATE doc WITH { ... } ... RETURN NEW
Parameters
- $init : array{field?: string, value?: mixed, prefix?: string, touch?: bool, count?: bool, options?: array|object|string|null, debug?: bool} = []
Tags
Return values
array<string|int, object>|int —The list of modified documents, or their count when count is true.
arrayRemove()
Removes one or several values from the array `field` of a single document.
public
arrayRemove([array{owner?: mixed, field?: string, value?: mixed, key?: string, prefix?: string, touch?: bool, options?: array|object|string|null, debug?: bool} $init = [] ]) : object|null
Generated AQL (scalar value):
... UPDATE doc WITH { field: REMOVE_VALUE(doc.field, @value) [, counter: LENGTH(...)] [, modified: ...] } ...
(an array value uses REMOVE_VALUES instead).
Parameters
- $init : array{owner?: mixed, field?: string, value?: mixed, key?: string, prefix?: string, touch?: bool, options?: array|object|string|null, debug?: bool} = []
Tags
Return values
object|null —The updated document, or null if no document matched.
bind()
Bind a value to an AQL query variable.
public
bind(mixed $value[, array<string|int, mixed> &$binds = [] ][, string|null $to = null ]) : string
Parameters
- $value : mixed
-
The value to bind to the query.
- $binds : array<string|int, mixed> = []
-
Reference to the array of existing bind variables.
- $to : string|null = null
-
Optional name of the bind variable. If null, a unique name is generated.
Tags
Return values
string —The formatted bind variable (including the "@" prefix as needed) for use in the query.
bindCollection()
Bind a collection name to an AQL query variable.
public
bindCollection([array<string|int, mixed> &$binds = [] ][, array<string|int, mixed> $init = [] ]) : string
Prepares a bind variable for a collection name. Uses the collection defined in $init or
falls back to $this->collection if none is provided.
Parameters
- $binds : array<string|int, mixed> = []
-
Reference to the array of existing bind variables. If null, a new array is used.
- $init : array<string|int, mixed> = []
-
Optional initialization array with keys:
- Arango::COLLECTION => the collection name to bind
- Arango::NAME => optional bind variable name
Tags
Return values
string —The formatted bind variable representing the collection.
bindView()
Bind the model's declared View name (`AQL::VIEW` block, {@see Search::NAME}) to an AQL query variable — collection bind parameters (`@@view`) are valid for View names as well.
public
bindView([array<string|int, mixed> &$binds = [] ]) : string
Parameters
- $binds : array<string|int, mixed> = []
-
Reference to the array of existing bind variables.
Tags
Return values
string —The formatted bind variable representing the View.
collectionCreate()
Creates a new collection if not exist.
public
collectionCreate(string $name[, array<string|int, mixed> $options = [] ]) : bool
Parameters
- $name : string
-
The name of the new collection
- $options : array<string|int, mixed> = []
-
- an array of options.
Options are:
- 'type' - 2 -> normal collection, 3 -> edge-collection
- 'waitForSync' - if set to true, then all removal operations will instantly be synchronised to disk / If this is not specified, then the collection's default sync behavior will be applied.
- 'isSystem' - false->user collection(default), true->system collection .
- 'keyOptions' - key options to use.
- 'distributeShardsLike' - name of prototype collection for identical sharding.
- 'numberOfShards' - number of shards for the collection.
- 'replicationFactor' - number of replicas to keep (default: 1).
- 'writeConcern' - minimum number of replicas to be successful when writing (default: 1).
- 'shardKeys' - array of shard key attributes.
- 'shardingStrategy' - sharding strategy to use in cluster.
- 'smartJoinAttribute' - attribute name for smart joins (if not shard key).
- 'schema' - collection schema.
Return values
bool —Returns true if the new collection is created.
collectionDrop()
Drops a collection if exist.
public
collectionDrop(string $name) : bool
Parameters
- $name : string
-
The name of the new collection
Return values
bool —Returns true if the new collection is dropped.
collectionExists()
Check if collection exists
public
collectionExists(string $name) : bool
Parameters
- $name : string
-
The name of the collection
Return values
boolcollectionRename()
Renames a collection if exist.
public
collectionRename(string $oldName, string $name) : bool
Parameters
- $oldName : string
-
The old name of the collection
- $name : string
-
The new name of the collection
Tags
Return values
bool —Returns true if the collection is renamed.
collectionTruncate()
Truncate a collection if exist.
public
collectionTruncate(string $name) : bool
Parameters
- $name : string
-
The name of the collection to truncate.
Return values
boolcreateIndex()
Creates an index on a collection on the server.
public
createIndex(string|Collection $collection, array<string|int, mixed>|IndexOptions $indexOptions) : array<string|int, mixed>|null
Parameters
- $collection : string|Collection
-
Collection name or Collection client handle.
- $indexOptions : array<string|int, mixed>|IndexOptions
-
An IndexOptions definition or an associative array of options for the index like array('type' => 'persistent', 'fields' => ['id','additionalType'], 'sparse' => false)
Tags
Return values
array<string|int, mixed>|null —The server response of the created index or null
debugQuery()
Debug the passed-in query and binds variables.
public
debugQuery(string $method, string $query, array<string|int, mixed>|null $binds) : void
Parameters
- $method : string
- $query : string
- $binds : array<string|int, mixed>|null
explain()
Explains an AQL query — returns the optimizer's execution plan as a typed {@see ExplainResult} (rules applied, collections, estimated cost, indexes actually used) **without executing the query**.
public
explain(AqlQuery|string $query[, array<string, mixed> $bindVars = [] ][, array<string, mixed> $options = [] ]) : ExplainResult
Parameters
- $query : AqlQuery|string
-
The AQL query to explain.
- $bindVars : array<string, mixed> = []
-
Bind variables (omit when
$queryis an AqlQuery). - $options : array<string, mixed> = []
-
Explain options (
allPlans,optimizer.rules, …).
Tags
Return values
ExplainResultfoundRows()
For a SELECT with a LIMIT clause, returns the number of rows that would be returned were there no LIMIT clause.
public
foundRows() : int
Return values
intgetDatabase()
Returns the ArangoDB database singleton reference.
public
getDatabase() : ArangoDB
Return values
ArangoDBgetDocuments()
Prepare, execute and returns an array of all documents with the passed-in AQL query.
public
getDocuments(string $query[, array<string|int, mixed> $bindVars = [] ][, array<string|int, mixed> $options = [] ][, bool $raw = false ][, null|SchemaResolver|Closure|string $schema = null ]) : array<string|int, mixed>
Parameters
- $query : string
-
The AQL query string to execute
- $bindVars : array<string|int, mixed> = []
-
Optional bind variables for the query
- $options : array<string|int, mixed> = []
-
Optional execution options
- $raw : bool = false
-
If true, returns the object raw (no schema or alter applied)
- $schema : null|SchemaResolver|Closure|string = null
-
The optional class name to map the document.
Tags
Return values
array<string|int, mixed>getExtra()
Returns the AQL current extra datas.
public
getExtra() : array<string|int, mixed>
Return values
array<string|int, mixed>getFirstResult()
Prepare, execute and returns the first result of the passed-in AQL query.
public
getFirstResult(string $query[, array<string|int, mixed> $bindVars = [] ][, array<string|int, mixed> $options = [] ][, bool $raw = false ][, null|SchemaResolver|Closure|string $schema = null ]) : mixed
Parameters
- $query : string
-
The AQL query string to execute
- $bindVars : array<string|int, mixed> = []
-
Optional bind variables for the query
- $options : array<string|int, mixed> = []
-
Optional execution options
- $raw : bool = false
-
If true, returns the object raw (no schema or alter applied)
- $schema : null|SchemaResolver|Closure|string = null
-
The optional class name to map the document.
Tags
getObject()
Prepare, execute and returns an object with the passed-in AQL query.
public
getObject(string $query[, array<string|int, mixed> $bindVars = [] ][, array<string|int, mixed> $options = [] ][, bool $raw = false ][, null|SchemaResolver|Closure|string $schema = null ]) : object|null
Parameters
- $query : string
-
The AQL query string to execute
- $bindVars : array<string|int, mixed> = []
-
Optional bind variables for the query
- $options : array<string|int, mixed> = []
-
Optional execution options
- $raw : bool = false
-
If true, returns the object raw (no schema or alter applied)
- $schema : null|SchemaResolver|Closure|string = null
-
The optional class name to map the document.
Tags
Return values
object|nullgetProfile()
Returns the typed profile of the last profiled query run (per-phase timings, {@see ExecutionStats}, warnings).
public
getProfile() : ProfileResult
Return values
ProfileResultgetResult()
Prepare, execute and returns an array with the passed-in AQL query.
public
getResult(string $query[, array<string|int, mixed> $bindVars = [] ][, array<string|int, mixed> $options = [] ][, bool $raw = false ][, null|SchemaResolver|Closure|string $schema = null ]) : object|null
Parameters
- $query : string
-
The AQL query string to execute
- $bindVars : array<string|int, mixed> = []
-
Optional bind variables for the query
- $options : array<string|int, mixed> = []
-
Optional execution options
- $raw : bool = false
-
If true, returns the object raw (no schema or alter applied)
- $schema : null|SchemaResolver|Closure|string = null
-
The optional class name to map the document.
Tags
Return values
object|nullgetStats()
Returns the typed execution statistics of the last query (scanned / filtered / time / memory …). Most meaningful right after a profiled `list()` / `get()` (see {@see Arango::PROFILE}).
public
getStats() : ExecutionStats
Return values
ExecutionStatsinitializeArrays()
Initialize the per-field embedded-array configuration from the `arrays` option.
public
initializeArrays([array<string|int, mixed> $init = [] ]) : static
Each entry is either an ArrayMode shorthand ('tags' => ArrayMode::SET) or
a richer definition ('tracks' => [ ArrayMode::LIST , Arango::COUNTER => 'numberOfTracks' ]).
Parameters
- $init : array<string|int, mixed> = []
Return values
staticinitializeCollection()
Sets the internal collection reference.
public
initializeCollection([array<string|int, mixed> $init = [] ][, string $type = CollectionType::DOCUMENT ]) : static
Parameters
- $init : array<string|int, mixed> = []
-
The options to lazy creates the collection (document or edge) or not.
- collection (string) Indicates if the name of the collection.
- indexes (array) The optional list of indexes to creates (if not exist and lazy).
- lazy (bool) Indicates if the collection is created if not exist — resolved through
LazyTrait::isLazy(), so a
lazyentry defined in the DI container always wins (orchestration kill-switch), then this init key, then the property default. - options (array) The options are:
- 'waitForSync' : if set to true, then all removal operations will instantly be synchronised to disk / If this is not specified, then the collection's default sync behavior will be applied.
- 'isSystem' : false->user collection(default), true->system collection .
- 'keyOptions' : key options to use.
- 'distributeShardsLike' : name of prototype collection for identical sharding.
- 'numberOfShards' : number of shards for the collection.
- 'replicationFactor' : number of replicas to keep (default: 1).
- 'writeConcern' : minimum number of replicas to be successful when writing (default: 1).
- 'shardKeys' : array of shard key attributes.
- 'shardingStrategy' : sharding strategy to use in cluster.
- 'smartJoinAttribute' : attribute name for smart joins (if not shard key).
- 'schema' : collection schema.
- $type : string = CollectionType::DOCUMENT
-
The default type of the collection (Default -> 'document' [2] )
Tags
Return values
staticinitializeDatabase()
Set the internal arangoDB reference.
public
initializeDatabase([array<string|int, mixed> $init = [] ][, ContainerInterface|null $container = null ]) : static
Parameters
- $init : array<string|int, mixed> = []
- $container : ContainerInterface|null = null
Tags
Return values
staticinitializeIndexes()
Sets the declared indexes of the collection from the init definition, normalizing a single {@see IndexOptions} value to a one-element list (a raw array always stays the index list) — so every consumer sees a plain `IndexOptions[]`: the {@see initializeCollection()} lazy provisioning and the {@see \oihana\arango\models\traits\DoctorTrait} diagnose/repair diffs.
public
initializeIndexes([array<string|int, mixed> $init = [] ]) : static
Parameters
- $init : array<string|int, mixed> = []
-
The init definition (reads the
Arango::INDEXESkey).
Return values
staticprepareAndExecute()
Prepare and execute an ArangoDB AQL query.
public
prepareAndExecute(string $query[, array<string|int, mixed> $bindVars = [] ][, array<string|int, mixed> $options = [] ]) : static
Parameters
- $query : string
- $bindVars : array<string|int, mixed> = []
- $options : array<string|int, mixed> = []
Tags
Return values
staticregisterProperty()
Register a specific dynamic property in the binds and values collection to generates a query.
public
registerProperty(string $name, mixed $value, array<string|int, mixed> &$binds, array<string|int, mixed> &$values[, string $prefix = Char::EMPTY ][, string $separator = ': ' ]) : void
Parameters
- $name : string
- $value : mixed
- $binds : array<string|int, mixed>
- $values : array<string|int, mixed>
- $prefix : string = Char::EMPTY
- $separator : string = ': '
streamDocuments()
Prepare, execute and returns a generator of documents with the passed-in AQL query.
public
streamDocuments(string $query[, array<string|int, mixed> $bindVars = [] ][, array<string|int, mixed> $options = [] ][, bool $raw = false ][, null|SchemaResolver|Closure|string $schema = null ]) : Generator<string|int, mixed>
Documents are yielded one by one, allowing efficient memory usage for large result sets.
Parameters
- $query : string
-
The AQL query string to execute
- $bindVars : array<string|int, mixed> = []
-
Optional bind variables for the query
- $options : array<string|int, mixed> = []
-
Optional execution options
- $raw : bool = false
-
If true, returns the object raw (no schema or alter applied)
- $schema : null|SchemaResolver|Closure|string = null
-
The optional class name to map the document.
Tags
Return values
Generator<string|int, mixed> —Generator yielding documents one by one
viewCreate()
Creates an `arangosearch` View if it does not already exist.
public
viewCreate(string $name[, array<string|int, mixed> $links = [] ][, array<string|int, mixed> $options = [] ]) : bool
Parameters
- $name : string
-
The name of the new View.
- $links : array<string|int, mixed> = []
-
Per-collection link map (collection name → link definition).
- $options : array<string|int, mixed> = []
-
Extra arangosearch options forwarded verbatim.
Return values
bool —Returns true if the new View has been created.
viewExists()
Checks if a View exists.
public
viewExists(string $name) : bool
Parameters
- $name : string
-
The name of the View.
Return values
boolarrayCounter()
Returns the configured length-counter attribute of an array field, or null.
protected
arrayCounter(string|null $field) : string|null
Parameters
- $field : string|null
Return values
string|nullarrayMode()
Resolves the {@see ArrayMode} of an array field, honouring an optional per-call `mode` override, then the declared configuration, then defaulting to LIST.
protected
arrayMode(string|null $field[, array<string|int, mixed> $init = [] ]) : string
Parameters
- $field : string|null
- $init : array<string|int, mixed> = []
Return values
stringarrayWith()
Builds the `WITH { ... }` object clause: the array field, its optional length counter, and the `modified` timestamp unless `touch` is disabled.
protected
arrayWith(string|null $field, string $arrayVar[, array<string|int, mixed> $init = [] ]) : string
Parameters
- $field : string|null
-
The array attribute name.
- $arrayVar : string
-
The AQL variable holding the new array (e.g. '__arr').
- $init : array<string|int, mixed> = []
Return values
stringensureArrayDefaults()
Builds an `ensure` closure that seeds the declared array fields to `[]` (and their counters to `0`) for any missing key of a document being created, then applies the optional user-supplied `ensure`. Returns the user closure unchanged when no array field is declared (so models without `AQL::ARRAYS` are untouched).
protected
ensureArrayDefaults([Closure|null $ensure = null ]) : Closure|null
Parameters
- $ensure : Closure|null = null
-
An optional user ensure closure to compose with.
Return values
Closure|nullprofileOptions()
Merges the cursor `profile` option into `$options` when the `$init` array requests profiling via {@see Arango::PROFILE} (`true` → profile level 2, or an explicit integer level). Returns `$options` unchanged otherwise.
protected
profileOptions(array<string|int, mixed> $init[, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
- $init : array<string|int, mixed>
-
The model input array (
list()/get()). - $options : array<string|int, mixed> = []
-
The cursor options to augment.
Return values
array<string|int, mixed>runArrayUpdate()
Compiles and executes a single-document array UPDATE (`FOR ... FILTER ... LET ... UPDATE ... RETURN NEW`), emitting the update signals around the write.
private
runArrayUpdate(string|null $field, array<string|int, mixed> $lets, string $filter, array<string|int, mixed> &$binds, array<string|int, mixed> $init) : object|null
Parameters
- $field : string|null
-
The array attribute name.
- $lets : array<string|int, mixed>
-
The ordered LET clauses producing the
__arrvariable. - $filter : string
-
The FILTER predicate locating the document.
- $binds : array<string|int, mixed>
-
The bind variables (mutated by reference).
- $init : array<string|int, mixed>