Oihana PHP Arango

DocumentsListTrait uses trait:short, trait:short

Provides list retrieval capabilities for ArangoDB document collections.

This trait combines multiple AQL-building sub-traits to construct flexible, feature-rich queries for retrieving documents from ArangoDB collections. It supports filtering, searching, sorting, pagination, and field selection.

Composed Traits:

  • ArangoTrait: Core ArangoDB database operations
  • ActiveTrait: Active/inactive status filtering
  • BindTrait: Collection binding and bind variable management
  • FacetTrait: Faceted filtering capabilities
  • FieldsTrait: Field selection and projection
  • FilterTrait: General filtering conditions
  • SearchTrait: Text-based search functionality
  • SortTrait: Result sorting capabilities
Tags
see
ArangoTrait

For core database operations

DocumentsStreamTrait

For memory-efficient streaming alternative

Table of Contents

Properties

$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).
buildListQuery()  : string
Builds an AQL query for listing documents with comprehensive filtering, sorting, and pagination.
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**.
explainList()  : ExplainResult
Explains the query that {@see list()} would run for the same `$init`, **without executing it**. Use it to check which indexes the list query actually uses, the optimizer rules that fire, and the estimated cost — straight from the same filter / facet / search / sort / pagination input.
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}).
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.
list()  : array<string|int, mixed>
Retrieves a list of documents from the collection with filtering, sorting, and pagination.
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.
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.

Properties

$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

$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
bool

buildListQuery()

Builds an AQL query for listing documents with comprehensive filtering, sorting, and pagination.

public buildListQuery([array<string|int, mixed> $init = [] ][, array<string|int, mixed> &$bindVars = [] ]) : string

This method orchestrates the construction of a complete AQL query by combining various query components (FOR, FILTER, SORT, LIMIT, RETURN) based on the provided initialization parameters. It delegates to specialized methods for each query aspect (filtering, sorting, etc.) and compiles them into a single executable AQL statement.

Generated Query Structure:

FOR doc IN @@collection
  [LET variables...]
  FILTER doc.active == [1|0] [&& facets] [&& filter] [&& search] [&& conditions]
  SORT field1 ASC, field2 DESC
  LIMIT offset, limit
  RETURN { ...fields }

Query Building Process:

  1. Extract configuration parameters (limit, offset, variables, debug)
  2. Build FOR clause with collection binding
  3. Construct FILTER clause combining active, facets, filter, and search
  4. Generate SORT clause from sort criteria
  5. Add LIMIT/OFFSET for pagination
  6. Define RETURN clause with field selection
  7. Compile all components into final query
  8. Optionally debug the generated query

Usage Example:

$bindVars = [];
$query = $model->buildListQuery([
    'active'  => true,
    'filter'  => ['status' => 'published'],
    'sort'    => ['createdAt' => 'DESC'],
    'limit'   => 50,
    'offset'  => 0,
    'fields'  => ['_key', 'title', 'author'],
    'debug'   => true
], $bindVars);
// Returns: "FOR doc IN @@collection FILTER doc.active == 1 && ..."
// $bindVars now contains: ['@collection' => 'myCollection', ...]
Parameters
$init : array<string|int, mixed> = []

Configuration array with optional parameters:

Query Variables:*

  • variables (array, optional) Additional AQL LET statements to declare variables in the query. Example: ['total = LENGTH(doc.items)', 'avg = SUM(doc.prices) / total'] Default: []

Pagination:*

  • limit (int, optional) Maximum number of documents to return. Set to 0 for no limit. Example: 50 Default: 0

  • offset (int, optional) Number of documents to skip before returning results. Useful for pagination when combined with limit. Example: 100 (skip first 100 documents) Default: 0

Filtering:*

  • active (?bool, optional) Filter by document active status. true for active only, false for inactive only, null to ignore this filter. Processed by prepareActive(). Default: null

  • facets (?array, optional) Array of facet-based filter conditions. Facets are typically used for categorical filtering (categories, tags, types, etc.). Processed by prepareFacets(). Example: ['category' => 'electronics', 'brand' => 'Apple'] Default: null

  • conditions (?array, optional) Array of custom AQL filter conditions. When provided, this completely overrides the automatic combination of active/facets/filter/search. Use this for complex custom filtering logic. Example: ['doc.price > 100', 'doc.stock > 0'] Default: null

  • filter (?array, optional) Array of general filter conditions applied as key-value pairs. Processed by prepareFilter(). Example: ['status' => 'published', 'author.verified' => true] Default: null

  • search (?array, optional) Array of search conditions for text-based filtering. Typically used for full-text or partial string matching. Processed by prepareSearch(). Example: ['title' => 'laptop', 'description' => 'gaming'] Default: null

Sorting:*

  • sort (?array, optional) Array defining sort criteria. Keys are field names (support dot notation), values are 'ASC' or 'DESC'. Multiple fields create compound sorting. Processed by prepareSort(). Example: ['priority' => 'DESC', 'createdAt' => 'ASC'] Default: null

Field Selection:*

  • fields (?array<string>, optional) Array of field names to include in returned documents. Supports dot notation for nested fields. If not provided, all document fields are returned. Processed by returnFields(). Example: ['_key', 'title', 'author.name', 'metadata.tags'] Default: null (returns all fields)

Output Transformation:*

  • skin (?string, optional) Name of the skin/transformation to apply to result documents. Applied during the alter() phase after query execution. Example: 'summary', 'detailed', 'api' Default: null

Query Binding:*

  • binds (array<string, mixed>, optional) Additional AQL bind variables to include in the query. Merged with auto-generated bind variables. Example: ['minPrice' => 100, 'category' => 'books'] Default: []

Debugging:*

  • debug (bool, optional) Enable query debugging. When true, the generated AQL query and bind variables are logged via debugQuery() before returning. Default: false
$bindVars : array<string|int, mixed> = []

Reference to an array where bind variables will be collected. This array is populated during query construction with all necessary bind variables (collection name, filter values, search terms, etc.). After the method returns, this array contains all variables needed to execute the query.

Example of populated bindVars:*

[
    '@collection' => 'products',
    'active' => 1,
    'status' => 'published',
    'minPrice' => 100
]
Tags
throws
BindException

If there's an error during bind variable processing, such as:

  • Invalid bind variable names (reserved keywords, invalid characters)
  • Type conversion failures
  • Collection binding errors
ConstantException
ContainerExceptionInterface

If there's an error accessing the dependency injection container while resolving services needed during query construction

NotFoundExceptionInterface

If a required service (like a filter handler) is not found in the dependency injection container

ReflectionException

If a reflection error occurs during internal processing, such as:

  • Analyzing filter or sort field structures
  • Inspecting schema classes for field validation
  • Dynamic method invocation failures
UnsupportedOperationException
DependencyException
NotFoundException
ValidationException
see
list()

For executing the built query and retrieving results

prepareActive()

For active status filter preparation

prepareFacets()

For facet filter preparation

prepareFilter()

For general filter preparation

prepareSearch()

For search condition preparation

prepareSort()

For sort criteria preparation

returnFields()

For field selection preparation

Return values
string

The compiled AQL query string ready for execution. The query is a complete, executable AQL statement that can be passed to ArangoDB along with the populated $bindVars.

Example Output:*

FOR doc IN @@collection
  FILTER doc.active == @active && doc.status == @status
  SORT doc.createdAt DESC
  LIMIT 0, 50
  RETURN { _key: doc._key, title: doc.title, price: doc.price }

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
    bool

    collectionRename()

    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
    throws
    ArangoException
    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
    bool

    createIndex()

    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
    throws
    ReflectionException
    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 $query is an AqlQuery).

    $options : array<string, mixed> = []

    Explain options (allPlans, optimizer.rules, …).

    Tags
    throws
    ArangoException
    Return values
    ExplainResult

    explainList()

    Explains the query that {@see list()} would run for the same `$init`, **without executing it**. Use it to check which indexes the list query actually uses, the optimizer rules that fire, and the estimated cost — straight from the same filter / facet / search / sort / pagination input.

    public explainList([array<string|int, mixed> $init = [] ]) : ExplainResult
    Parameters
    $init : array<string|int, mixed> = []

    The same input array accepted by list().

    Tags
    throws
    ArangoException
    BindException
    ConstantException
    ContainerExceptionInterface
    DependencyException
    NotFoundException
    NotFoundExceptionInterface
    ReflectionException
    UnsupportedOperationException
    ValidationException
    see
    list()

    For the executed counterpart.

    Return values
    ExplainResult

    The typed execution plan.

    foundRows()

    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
    int

    getDocuments()

    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
    throws
    ArangoException
    ContainerExceptionInterface
    DependencyException
    NotFoundException
    NotFoundExceptionInterface
    ReflectionException
    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
    throws
    ArangoException
    ContainerExceptionInterface
    DependencyException
    NotFoundException
    NotFoundExceptionInterface
    ReflectionException

    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
    throws
    ArangoException
    ContainerExceptionInterface
    NotFoundExceptionInterface
    ReflectionException
    DependencyException
    NotFoundException
    Return values
    object|null

    getProfile()

    Returns the typed profile of the last profiled query run (per-phase timings, {@see ExecutionStats}, warnings).

    public getProfile() : ProfileResult
    Return values
    ProfileResult

    getResult()

    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
    throws
    ArangoException
    ContainerExceptionInterface
    DependencyException
    NotFoundException
    NotFoundExceptionInterface
    ReflectionException
    Return values
    object|null

    getStats()

    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
    ExecutionStats

    initializeCollection()

    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 lazy entry 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
    throws
    ReflectionException
    ContainerExceptionInterface

    If an error occurs while reading the container lazy entry.

    NotFoundExceptionInterface

    If the container lazy entry vanishes between check and read.

    Return values
    static

    initializeDatabase()

    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
    throws
    ContainerExceptionInterface
    NotFoundExceptionInterface
    Return values
    static

    initializeIndexes()

    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::INDEXES key).

    Return values
    static

    list()

    Retrieves a list of documents from the collection with filtering, sorting, and pagination.

    public list([array<string|int, mixed> $init = [] ]) : array<string|int, mixed>

    This is the main entry point for fetching multiple documents from an ArangoDB collection. It constructs an AQL query using buildListQuery(), executes it, and returns all matching documents loaded into memory. Each document is processed through schema mapping (if configured) and transformation via the alter() method.

    When to Use:

    • When you need all results in memory for further processing
    • For small to medium result sets (< 10,000 documents)
    • When you need to count, sort, or filter results in PHP
    • For API responses that return complete datasets

    Performance Considerations:

    • All documents are loaded into memory at once
    • For large datasets (> 10,000 documents), consider using stream() instead
    • Use limit and offset for pagination to control memory usage
    • Use fields to reduce data transfer by selecting only needed fields

    Generated AQL Query Structure:

    FOR doc IN @@collection
      FILTER doc.active == [1|0] [&& facets] [&& filter] [&& search] [&& conditions]
      SORT field1 ASC, field2 DESC
      LIMIT offset, limit
      RETURN { ...fields }
    

    Usage Examples:

    Basic usage:

    $documents = $model->list();
    // Returns all documents from the collection
    

    With filtering and pagination:

    $documents = $model->list([
        'active' => true,
        'filter' => ['status' => 'published'],
        'limit'  => 50,
        'offset' => 0
    ]);
    // Returns first 50 active, published documents
    

    Complex query with all features:

    $documents = $model->list([
        'active'  => true,
        'facets'  => ['category' => 'electronics'],
        'filter'  => ['price' => ['$gte' => 100]],
        'search'  => ['title' => 'laptop'],
        'sort'    => ['priority' => 'DESC', 'createdAt' => 'ASC'],
        'limit'   => 100,
        'offset'  => 0,
        'fields'  => ['_key', 'title', 'price', 'stock'],
        'skin'    => 'api'
    ]);
    

    With custom binds:

    $documents = $model->list([
        'conditions' => ['doc.price >= @minPrice', 'doc.stock > 0'],
        'binds'      => ['minPrice' => 500]
    ]);
    
    Parameters
    $init : array<string|int, mixed> = []

    Configuration array with optional parameters:

    Query Binding:*

    • binds (array<string, mixed>, optional) Additional AQL bind variables to include in the query. Merged with auto-generated bind variables. Default: []

    Pagination:*

    • limit (int, optional) Maximum number of documents to return. Set to 0 for no limit. When > 0, enables full count calculation for pagination metadata. Default: 0

    • offset (int, optional) Number of documents to skip before returning results. Useful for pagination when combined with limit. Default: 0

    Filtering:*

    • active (?bool, optional) Filter by active status. true returns only active documents, false returns only inactive documents, null ignores this filter. Default: null

    • facets (?array, optional) Array of facet conditions for categorical filtering. Processed by prepareFacets(). Example: ['category' => 'books', 'language' => 'en'] Default: null

    • conditions (?array, optional) Array of custom filter conditions. When provided, this overrides the automatic combination of active/facets/filter/search. Example: ['doc.price > 100', 'doc.stock > 0'] Default: null

    • filter (?array, optional) Array of general filter conditions. Processed by prepareFilter(). Example: ['status' => 'published', 'featured' => true] Default: null

    • search (?array, optional) Array of search conditions for text-based filtering. Processed by prepareSearch(). Example: ['title' => 'search term', 'tags' => 'important'] Default: null

    Sorting:*

    • sort (?array, optional) Array defining sort criteria. Keys are field names, values are 'ASC' or 'DESC'. Processed by prepareSort(). Example: ['createdAt' => 'DESC', 'title' => 'ASC'] Default: null

    Field Selection:*

    • fields (?array<string>, optional) Array of specific field names to return. Supports dot notation. If not provided, all document fields are returned. Processed by returnFields(). Example: ['_key', 'title', 'author.name', 'publishedAt'] Default: null (all fields)

    Output Transformation:*

    • skin (?string, optional) Name of the skin/transformation to apply to result documents. Applied during the alter() phase. Example: 'summary', 'detailed' Default: null

    Query Variables:*

    • variables (?array, optional) Additional AQL LET statements to declare in the query. Default: []

    Debugging:*

    • debug (?bool, optional) Enable query debugging. When true, logs the AQL query and bind variables. Default: false
    Tags
    throws
    ArangoException

    If there's an error during ArangoDB query execution, such as:

    • Invalid AQL syntax in the generated query
    • Collection not found or not accessible
    • Connection timeout or network issues
    • Insufficient permissions
    • Query timeout (exceeded max execution time)
    BindException

    If there's an error binding parameters to the AQL query, such as:

    • Invalid bind variable names (reserved keywords, special characters)
    • Type mismatch in bind values
    • Collection binding errors
    ConstantException
    ContainerExceptionInterface

    If there's an error accessing the dependency injection container while resolving services needed for query execution or result processing

    DependencyException
    NotFoundException
    NotFoundExceptionInterface

    If a required service is not found in the dependency injection container

    ReflectionException

    If a reflection error occurs during processing, such as:

    • Schema class not found or not accessible
    • Invalid schema structure
    • Property hydration errors
    • Method invocation failures during alter()
    UnsupportedOperationException
    ValidationException
    see
    buildListQuery()

    For the query construction logic

    getDocuments()

    For the underlying execution and transformation

    stream()

    For memory-efficient streaming alternative

    foundRows()

    For getting total count without limit (when limit is set)

    Return values
    array<string|int, mixed>

    An array of matching documents. Each document is:

    • Retrieved from ArangoDB based on the query
    • Mapped to the configured schema class (if set via $this->schema)
    • Transformed via the alter() method (applies skins, conversions, etc.)

    Returns an empty array if:

    • No documents match the query criteria
    • The collection is empty
    • All matching documents are filtered out by conditions

    Example Return Structure:*

    [
        0 => ProductSchema {
            _key: 'product_001',
            title: 'Gaming Laptop',
            price: 1299.99,
            stock: 5
        },
        1 => ProductSchema {
            _key: 'product_002',
            title: 'Office Laptop',
            price: 899.99,
            stock: 12
        }
    ]
    

    prepareAndExecute()

    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
    throws
    ArangoException
    Return values
    static

    registerProperty()

    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
    throws
    ArangoException
    ContainerExceptionInterface
    DependencyException
    NotFoundException
    NotFoundExceptionInterface
    ReflectionException
    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
    bool

    profileOptions()

    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>
    On this page

    Search results