Provides management of collections

The collection handler fetches collection data from the server and creates collections on the server.

package ArangoDBClient
since 0.2
inherited_from \ArangoDBClient\Handler

 Methods

Construct a new handler

__construct(\ArangoDBClient\Connection $connection) 
Inherited

Parameters

$connection

\ArangoDBClient\Connection
  • connection to be used

Returns all documents of a collection

all(mixed $collection, array $options = array()) : \ArangoDBClient\Cursor

Parameters

$collection

mixed
  • collection as string or object

$options

array
  • optional array of options.

    Options are :

  • '_sanitize' - True to remove _id and _rev attributes from result documents. Defaults to false.
  • '_hiddenAttributes' - Set an array of hidden attributes for created documents.

    This is actually the same as setting hidden attributes using setHiddenAttributes() on a document.
    The difference is, that if you're returning a result set of documents, the getAll() is already called
    and the hidden attributes would not be applied to the attributes.

  • 'batchSize' - can optionally be used to tell the server to limit the number of results to be transferred in one batch
  • 'skip' - Optional, The number of documents to skip in the query.
  • 'limit' - Optional, The maximal amount of documents to return. 'skip' is applied before the limit restriction.
  • Exceptions

    \ArangoDBClient\Exception
    \ArangoDBClient\ClientException

    Returns

    \ArangoDBClient\Cursor- documents

    Get a random document from the collection.

    any(mixed $collection) : \ArangoDBClient\Document

    This will throw if the document cannot be fetched from the server

    since 1.2

    Parameters

    $collection

    mixed
    • collection as string or object

    Exceptions

    \ArangoDBClient\Exception

    Returns

    \ArangoDBClient\Document- the document fetched from the server

    Get document(s) by specifying an example

    byExample(mixed $collection, mixed $document, array $options = array()) : \ArangoDBClient\cursor

    This will throw if the list cannot be fetched from the server

    Parameters

    $collection

    mixed
    • collection as string or object

    $document

    mixed
    • the example document as a Document object or an array

    $options

    array
    • optional, prior to v1.0.0 this was a boolean value for sanitize, since v1.0.0 it's an array of options.

      Options are :

    • '_sanitize' - True to remove _id and _rev attributes from result documents. Defaults to false.
    • '_hiddenAttributes' - Set an array of hidden attributes for created documents.

      This is actually the same as setting hidden attributes using setHiddenAttributes() on a document.
      The difference is, that if you're returning a result set of documents, the getAll() is already called
      and the hidden attributes would not be applied to the attributes.

    • 'batchSize' - can optionally be used to tell the server to limit the number of results to be transferred in one batch
    • 'skip' - Optional, The number of documents to skip in the query.
    • 'limit' - Optional, The maximal amount of documents to return. 'skip' is applied before the limit restriction.

    Exceptions

    \ArangoDBClient\Exception

    Returns

    \ArangoDBClient\cursor- Returns a cursor containing the result

    Get the number of documents in a collection

    count(mixed $collection) : integer

    This will throw if the collection cannot be fetched from the server

    Parameters

    $collection

    mixed
    • collection id as a string or number

    Exceptions

    \ArangoDBClient\Exception

    Returns

    integer- the number of documents in the collection

    Creates a new collection on the server

    create(mixed $collection, array $options = array()) : mixed

    This will add the collection on the server and return its id The id is mainly returned for backwards compatibility, but you should use the collection name for any reference to the collection. * This will throw if the collection cannot be created

    Parameters

    $collection

    mixed
    • collection object to be created on the server or a string with the name

    $options

    array
    • 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.
    • 'journalSize' - journalSize value.
    • 'isSystem' - false->user collection(default), true->system collection .
    • 'isVolatile' - false->persistent collection(default), true->volatile (in-memory) 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).
    • 'minReplicationFactor' - 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).

    Exceptions

    \ArangoDBClient\Exception

    Returns

    mixed- id of collection created

    Create a fulltext index

    createFulltextIndex(mixed $collection, array $fields, integer $minLength = null, boolean $inBackground = false) : array
    deprecated use CollectionHandler::createIndex instead

    Parameters

    $collection

    mixed
    • collection as string or object

    $fields

    array
    • an array of fields

    $minLength

    integer
    • the minimum length of words to index

    $inBackground

    boolean
    • true if index shall be created in background

    Exceptions

    \ArangoDBClient\Exception

    Returns

    array- server response of the created index

    Create a geo index

    createGeoIndex(mixed $collection, array $fields, boolean $geoJson = null, boolean $inBackground = false) : array
    deprecated use CollectionHandler::createIndex instead

    Parameters

    $collection

    mixed
    • collection as string or object

    $fields

    array
    • an array of fields

    $geoJson

    boolean
    • whether to use geoJson or not

    $inBackground

    boolean
    • true if index shall be created in background

    Exceptions

    \ArangoDBClient\Exception

    Returns

    array- server response of the created index

    Create a hash index

    createHashIndex(mixed $collection, array $fields, boolean $unique = null, boolean $sparse = null, boolean $inBackground = false) : array
    deprecated use CollectionHandler::createIndex instead

    Parameters

    $collection

    mixed
    • the collection as name or object

    $fields

    array
    • an array of fields

    $unique

    boolean
    • whether the values in the index should be unique or not

    $sparse

    boolean
    • whether the index should be sparse

    $inBackground

    boolean
    • true if index shall be created in background

    Exceptions

    \ArangoDBClient\Exception

    Returns

    array- server response of the created index

    Creates an index on a collection on the server

    createIndex(mixed $collection, array $indexOptions) : array

    This will create an index on the collection on the server and return its id

    This will throw if the index cannot be created

    since 3.5

    Parameters

    $collection

    mixed
    • collection as string or object

    $indexOptions

    array
    • an associative array of options for the index like array('type' => hash, 'fields' => ..., 'sparse' => false)

    Exceptions

    \ArangoDBClient\Exception

    Returns

    array- server response of the created index

    Create a persistent index

    createPersistentIndex(mixed $collection, array $fields, boolean $unique = null, boolean $sparse = null, boolean $inBackground = false) : array
    deprecated use CollectionHandler::createIndex instead

    Parameters

    $collection

    mixed
    • collection as string or object

    $fields

    array
    • an array of fields

    $unique

    boolean
    • whether the index is unique or not

    $sparse

    boolean
    • whether the index should be sparse

    $inBackground

    boolean
    • true if index shall be created in background

    Exceptions

    \ArangoDBClient\Exception

    Returns

    array- server response of the created index

    Create a skip-list index

    createSkipListIndex(mixed $collection, array $fields, boolean $unique = null, boolean $sparse = null, boolean $inBackground = false) : array
    deprecated use CollectionHandler::createIndex instead

    Parameters

    $collection

    mixed
    • collection as string or object

    $fields

    array
    • an array of fields

    $unique

    boolean
    • whether the index is unique or not

    $sparse

    boolean
    • whether the index should be sparse

    $inBackground

    boolean
    • true if index shall be created in background

    Exceptions

    \ArangoDBClient\Exception

    Returns

    array- server response of the created index

    Create a TTL index

    createTtlIndex(mixed $collection, array $fields, \ArangoDBClient\number $expireAfter, boolean $inBackground = false) : array
    deprecated use CollectionHandler::createIndex instead

    Parameters

    $collection

    mixed
    • collection as string or object

    $fields

    array
    • an array of fields (only a single one allowed)

    $expireAfter

    \ArangoDBClient\number
    • number of seconds after index value after which documents expire

    $inBackground

    boolean
    • true if index shall be created in background

    Exceptions

    \ArangoDBClient\Exception

    Returns

    array- server response of the created index

    Drop a collection

    drop(mixed $collection, array $options = array()) : boolean

    Parameters

    $collection

    mixed
    • collection id as string or number or collection object

    $options

    array
    • an array of options for the drop operation

    Exceptions

    \ArangoDBClient\Exception

    Returns

    boolean- always true, will throw if there is an error

    Drop an index

    dropIndex(mixed $collection, mixed $indexHandle = null) : boolean

    Parameters

    $collection

    mixed
    • collection as string or object

    $indexHandle

    mixed
    • index handle (collection name / index id)

    Exceptions

    \ArangoDBClient\Exception

    Returns

    boolean- always true, will throw if there is an error

    Get figures for a collection

    figures(mixed $collection) : array

    This will throw if the collection cannot be fetched from the server

    Parameters

    $collection

    mixed
    • collection id as a string or number

    Exceptions

    \ArangoDBClient\Exception

    Returns

    array- the figures for the collection

    Get the first document matching a given example.

    firstExample(mixed $collection, mixed $document, array $options = array()) : \ArangoDBClient\Document

    This will throw if the document cannot be fetched from the server

    since 1.2

    Parameters

    $collection

    mixed
    • collection as string or object

    $document

    mixed
    • the example document as a Document object or an array

    $options

    array
    • optional, an array of options.

      Options are :

    • '_sanitize' - True to remove _id and _rev attributes from result documents. Defaults to false.
    • '_hiddenAttributes' - Set an array of hidden attributes for created documents.

      This is actually the same as setting hidden attributes using setHiddenAttributes() on a document.
      The difference is, that if you're returning a result set of documents, the getAll() is already called
      and the hidden attributes would not be applied to the attributes.

    Exceptions

    \ArangoDBClient\Exception

    Returns

    \ArangoDBClient\Document- the document fetched from the server

    Get document(s) by a fulltext query

    fulltext(mixed $collection, mixed $attribute, mixed $query, array $options = array()) : \ArangoDBClient\cursor

    This will find all documents from the collection that match the fulltext query specified in query. In order to use the fulltext operator, a fulltext index must be defined for the collection and the specified attribute.

    deprecated use AQL queries instead

    Parameters

    $collection

    mixed
    • collection id as string or number

    $attribute

    mixed
    • The attribute that contains the texts.

    $query

    mixed
    • The fulltext query.

    $options

    array
    • optional, prior to v1.0.0 this was a boolean value for sanitize, since v1.0.0 it's an array of options.

      Options are :

    • '_sanitize' - True to remove _id and _rev attributes from result documents. Defaults to false.
    • '_hiddenAttributes' - Set an array of hidden attributes for created documents.

      This is actually the same as setting hidden attributes using setHiddenAttributes() on a document.
      The difference is, that if you're returning a result set of documents, the getAll() is already called
      and the hidden attributes would not be applied to the attributes.

    • 'batchSize' - can optionally be used to tell the server to limit the number of results to be transferred in one batch
    • 'skip' - Optional, The number of documents to skip in the query.
    • 'limit' - Optional, The maximal amount of documents to return. 'skip' is applied before the limit restriction.
    • 'index' - If given, the identifier of the fulltext-index to use.

    Exceptions

    \ArangoDBClient\Exception

    Returns

    \ArangoDBClient\cursor- Returns a cursor containing the result

    Get information about a collection

    get(mixed $collection) : \ArangoDBClient\Collection

    This will throw if the collection cannot be fetched from the server

    Parameters

    $collection

    mixed
    • collection id as a string or number

    Exceptions

    \ArangoDBClient\Exception

    Returns

    \ArangoDBClient\Collection- the collection fetched from the server

    Get list of all available collections per default with the collection names as index.

    getAllCollections(array $options = array()) : array

    Returns empty array if none are available.

    Parameters

    $options

    array
    • optional - an array of options.

      Options are :

    • 'excludeSystem' - With a value of true, all system collections will be excluded from the response.
    • 'keys' - With a value of "collections", the index of the resulting array is numerical, With a value of "names", the index of the resulting array are the collection names.

    Exceptions

    \ArangoDBClient\Exception
    \ArangoDBClient\ClientException

    Returns

    array

    Get the list of all documents' ids from a collection

    getAllIds(mixed $collection) : array

    This will throw if the list cannot be fetched from the server

    Parameters

    $collection

    mixed
    • collection id as string or number

    Exceptions

    \ArangoDBClient\Exception

    Returns

    array- ids of documents in the collection

    Calculate a checksum of the collection.

    getChecksum(mixed $collection, boolean $withRevisions = false, boolean $withData = false) : array

    Will calculate a checksum of the meta-data (keys and optionally revision ids) and optionally the document data in the collection.

    Parameters

    $collection

    mixed
    • collection as string or object

    $withRevisions

    boolean
    • optional boolean whether or not to include document revision ids in the checksum calculation.

    $withData

    boolean
    • optional boolean whether or not to include document body data in the checksum calculation.

    Exceptions

    \ArangoDBClient\Exception

    Returns

    array- array containing keys "checksum" and "revision"

    Gets the collectionId from the given collectionObject or string/integer

    getCollectionId(mixed $collection) : mixed

    Parameters

    $collection

    mixed

    Returns

    mixed

    Gets the collectionId from the given collectionObject or string/integer

    getCollectionName(mixed $collection) : mixed

    Parameters

    $collection

    mixed

    Returns

    mixed

    Get the information about an index in a collection

    getIndex(string $collection, string $indexId) : array

    Parameters

    $collection

    string
    • the id of the collection

    $indexId

    string
    • the id of the index

    Exceptions

    \ArangoDBClient\Exception
    \ArangoDBClient\ClientException

    Returns

    array

    Get indexes of a collection

    getIndexes(mixed $collection) : array

    This will throw if the collection cannot be fetched from the server

    Parameters

    $collection

    mixed
    • collection as string or object

    Exceptions

    \ArangoDBClient\Exception

    Returns

    array$data - the indexes result-set from the server

    Get properties of a collection

    getProperties(mixed $collection) : \ArangoDBClient\Collection

    This will throw if the collection cannot be fetched from the server

    Parameters

    $collection

    mixed
    • collection id as a string or number

    Exceptions

    \ArangoDBClient\Exception

    Returns

    \ArangoDBClient\Collection- the collection fetched from the server

    Get the responsible shard for a document

    getResponsibleShard(mixed $collection, mixed $document) : string
    since 3.5

    Parameters

    $collection

    mixed
    • collection as string or object

    $document

    mixed
    • document

    Exceptions

    \ArangoDBClient\Exception

    Returns

    string- shard id

    Returns the Collections revision ID

    getRevision(mixed $collection) : array

    The revision id is a server-generated string that clients can use to check whether data in a collection has changed since the last revision check.

    Parameters

    $collection

    mixed
    • collection as string or object

    Exceptions

    \ArangoDBClient\Exception

    Returns

    array- containing a key revision

    Get the shards of a collection

    getShards(mixed $collection) : array
    since 3.5

    Parameters

    $collection

    mixed
    • collection as string or object

    Exceptions

    \ArangoDBClient\Exception

    Returns

    array- array with shard ids

    Check if a collection exists

    has(mixed $collection) : boolean

    This will call self::get() internally and checks if there was an exception thrown which represents an 404 request.

    Parameters

    $collection

    mixed
    • collection id as a string or number

    Exceptions

    \ArangoDBClient\Exception When any other error than a 404 occurs

    Returns

    boolean

    Import documents into a collection

    import($collection, string|array $importData, array $options = array()) : array

    This will throw on all errors except insertion errors

    see

    Parameters

    $collection

    mixed $collection - collection as string or object

    $importData

    stringarray
    • The data to import. This can be a string holding the data according to the type of import, or an array of documents

    $options

    array
    • optional - an array of options.

      Options are :

    • 'type' - if type is not set or it's set to '' or null, the Header-Value format must be provided in the import file.

    • if set to 'documents', then the file's content must have its documents line by line. Each line will be interpreted as a document.
    • if set to 'array' then the file's content must provide the documents as a list of documents instead of the above line by line.

    • More info on how the import functionality works: https://github.com/triAGENS/ArangoDB/wiki/HttpImport


    • 'createCollection' - If true, create the collection if it does not exist. Defaults to false
    •                           Other options as described in API Documentation*

    Exceptions

    \ArangoDBClient\Exception
    \ArangoDBClient\ClientException

    Returns

    array

    Import documents from a file

    importFromFile($collection, mixed $importFileName, array $options = array()) : array

    This will throw on all errors except insertion errors

    Parameters

    $collection

    $importFileName

    mixed
    • The filename that holds the import data.

    $options

    array
    • optional - an array of options.

      Options are :
      'type' - if type is not set or it's set to '' or null, the Header-Value format must be provided in the import file.

    • if set to 'documents', then the file's content must have its documents line by line. Each line will be interpreted as a document.
    • if set to 'array' then the file's content must provide the documents as a list of documents instead of the above line by line.

    • More info on how the import functionality works: https://github.com/triAGENS/ArangoDB/wiki/HttpImport


    • 'createCollection' - If true, create the collection if it does not exist. Defaults to false

    Exceptions

    \ArangoDBClient\Exception

    Returns

    array- returns an array with the server's response data from the import command

    Creates an index on a collection on the server

    index(mixed $collection, string $type, array $attributes = array(), boolean $unique = false, array $indexOptions = array()) : array

    This will create an index on the collection on the server and return its id

    This will throw if the index cannot be created

    deprecated use CollectionHandler::createIndex instead

    Parameters

    $collection

    mixed
    • collection as string or object

    $type

    string
    • index type: hash, skiplist, geo, ttl, fulltext, or persistent

    $attributes

    array
    • an array of attributes that can be defined like array('a') or array('a', 'b.c')

    $unique

    boolean
    • true/false to create a unique index

    $indexOptions

    array
    • an associative array of options for the index like array('geoJson' => true, 'sparse' => false)

    Exceptions

    \ArangoDBClient\Exception

    Returns

    array- server response of the created index

    Checks if the collectionId given, is valid. Returns true if it is, or false if it is not.

    isValidCollectionId($collectionId) : boolean

    Parameters

    $collectionId

    Returns

    boolean

    Load a collection into the server's memory

    load(mixed $collection) : \ArangoDBClient\HttpResponse

    This will load the given collection into the server's memory.

    Parameters

    $collection

    mixed
    • collection as string or object

    Exceptions

    \ArangoDBClient\Exception

    Returns

    \ArangoDBClient\HttpResponse- HTTP response object

    Bulk lookup documents by specifying an array of keys

    lookupByKeys(mixed $collection, array $keys, array $options = array()) : array

    This will throw on any error

    since 2.6

    Parameters

    $collection

    mixed
    • collection as string or object

    $keys

    array
    • array of document keys

    $options

    array
    • optional array of options.

      Options are :

    • '_sanitize' - True to remove _id and _rev attributes from result documents. Defaults to false.
    • '_hiddenAttributes' - Set an array of hidden attributes for created documents.

    Exceptions

    \ArangoDBClient\Exception

    Returns

    array- an array containing all documents found for the keys specified. note that if for a given key not document is found, it will not be returned nor will the document's non-existence be reported.

    Get document(s) by specifying near

    near(mixed $collection, double $latitude, double $longitude, array $options = array()) : \ArangoDBClient\Cursor

    This will throw if the list cannot be fetched from the server

    deprecated use AQL queries instead

    Parameters

    $collection

    mixed
    • collection as string or object

    $latitude

    double
    • The latitude of the coordinate.

    $longitude

    double
    • The longitude of the coordinate.

    $options

    array
    • optional array of options.

      Options are :

    • '_sanitize' - True to remove _id and _rev attributes from result documents. Defaults to false.
    • '_hiddenAttributes' - Set an array of hidden attributes for created documents.

      This is actually the same as setting hidden attributes using setHiddenAttributes() on a document.
      The difference is, that if you're returning a result set of documents, the getAll() is already called
      and the hidden attributes would not be applied to the attributes.

    • 'distance' - If given, the attribute key used to store the distance. (optional)
    • 'batchSize' - can optionally be used to tell the server to limit the number of results to be transferred in one batch
    • 'skip' - Optional, The number of documents to skip in the query.
    • 'limit' - Optional, The maximal amount of documents to return. 'skip' is applied before the limit restriction.

    Exceptions

    \ArangoDBClient\Exception

    Returns

    \ArangoDBClient\Cursor- documents matching the example [0...n]

    Get document(s) by specifying range

    range(mixed $collection, string $attribute, mixed $left, mixed $right, array $options = array()) : \ArangoDBClient\Cursor

    This will throw if the list cannot be fetched from the server

    deprecated use AQL queries instead

    Parameters

    $collection

    mixed
    • collection as string or object

    $attribute

    string
    • the attribute path , like 'a', 'a.b', etc...

    $left

    mixed
    • The lower bound.

    $right

    mixed
    • The upper bound.

    $options

    array
    • optional array of options.

      Options are :

    • '_sanitize' - True to remove _id and _rev attributes from result documents. Defaults to false.
    • '_hiddenAttributes' - Set an array of hidden attributes for created documents.

      This is actually the same as setting hidden attributes using setHiddenAttributes() on a document.
      The difference is, that if you're returning a result set of documents, the getAll() is already called
      and the hidden attributes would not be applied to the attributes.

    • 'closed' - If true, use interval including left and right, otherwise exclude right, but include left.
    • 'batchSize' - can optionally be used to tell the server to limit the number of results to be transferred in one batch
    • 'skip' - Optional, The number of documents to skip in the query.
    • 'limit' - Optional, The maximal amount of documents to return. 'skip' is applied before the limit restriction.

    Exceptions

    \ArangoDBClient\Exception

    Returns

    \ArangoDBClient\Cursor- documents matching the example [0...n]

    Remove document(s) by specifying an example

    removeByExample(mixed $collection, mixed $document, array $options = array()) : integer

    This will throw on any error

    since 1.2

    Parameters

    $collection

    mixed
    • collection as string or object

    $document

    mixed
    • the example document as a Document object or an array

    $options

    array
    • optional - an array of options.

      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.
    •                         
    • 'limit' - Optional, The maximal amount of documents to return. 'skip' is applied before the limit restriction.

    Exceptions

    \ArangoDBClient\Exception

    Returns

    integer- number of documents that were deleted

    Remove document(s) by specifying an array of keys

    removeByKeys(mixed $collection, array $keys, array $options = array()) : array

    This will throw on any error

    since 2.6

    Parameters

    $collection

    mixed
    • collection as string or object

    $keys

    array
    • array of document keys

    $options

    array
    • optional - an array of options.

      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.

    Exceptions

    \ArangoDBClient\Exception

    Returns

    array- an array containing an attribute 'removed' with the number of documents that were deleted, an an array 'ignored' with the number of not removed keys/documents

    Rename a collection

    rename(mixed $collection, string $name) : boolean

    Parameters

    $collection

    mixed
    • collection as string or object

    $name

    string
    • new name for collection

    Exceptions

    \ArangoDBClient\Exception

    Returns

    boolean- always true, will throw if there is an error

    Replace document(s) matching a given example

    replaceByExample(mixed $collection, mixed $example, mixed $newValue, mixed $options = array()) : boolean

    This will replace the document(s) on the server

    This will throw if the document cannot be replaced

    deprecated use AQL queries instead
    since 1.2

    Parameters

    $collection

    mixed
    • collection as string or object

    $example

    mixed
    • the example document as a Document object or an array

    $newValue

    mixed
    • patch document or array which contains the attributes and values to be replaced

    $options

    mixed
    • optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)

      Options are :

    • 'keepNull' - can be used to instruct ArangoDB to delete existing attributes instead setting their values to null. Defaults to true (keep attributes when set to null)
    • 'waitForSync' - can be used to force synchronisation of the document replace operation to disk even in case that the waitForSync flag had been disabled for the entire collection
    • 'limit' - can be used set a limit on how many documents to replace at most. If limit is specified but is less than the number of documents in the collection, it is undefined which of the documents will be replaced.

    Exceptions

    \ArangoDBClient\Exception

    Returns

    boolean- always true, will throw if there is an error

    Sets the document class to use

    setDocumentClass(string $class) : \ArangoDBClient\DocumentClassable
    Inherited

    Parameters

    $class

    string

    Document class to use

    Returns

    \ArangoDBClient\DocumentClassable

    Sets the edge class to use

    setEdgeClass(string $class) : \ArangoDBClient\DocumentClassable
    Inherited

    Parameters

    $class

    string

    Edge class to use

    Returns

    \ArangoDBClient\DocumentClassable

    Truncate a collection

    truncate(mixed $collection) : boolean

    This will remove all documents from the collection but will leave the metadata and indexes intact.

    Parameters

    $collection

    mixed
    • collection id as string or number or collection object

    Exceptions

    \ArangoDBClient\Exception

    Returns

    boolean- always true, will throw if there is an error

    Unload a collection from the server's memory

    unload(mixed $collection) : \ArangoDBClient\HttpResponse

    This will unload the given collection from the server's memory.

    Parameters

    $collection

    mixed
    • collection as string or object

    Exceptions

    \ArangoDBClient\Exception

    Returns

    \ArangoDBClient\HttpResponse- HTTP response object

    Update document(s) matching a given example

    updateByExample(mixed $collection, mixed $example, mixed $newValue, mixed $options = array()) : boolean

    This will update the document(s) on the server

    This will throw if the document cannot be updated

    deprecated use AQL queries instead
    since 1.2

    Parameters

    $collection

    mixed
    • collection as string or number

    $example

    mixed
    • the example document as a Document object or an array

    $newValue

    mixed
    • patch document or array which contains the attributes and values to be updated

    $options

    mixed
    • optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)

      Options are :

    • 'keepNull' - can be used to instruct ArangoDB to delete existing attributes instead setting their values to null. Defaults to true (keep attributes when set to null)
    • 'waitForSync' - can be used to force synchronisation of the document update operation to disk even in case that the waitForSync flag had been disabled for the entire collection
    • 'limit' - can be used set a limit on how many documents to update at most. If limit is specified but is less than the number of documents in the collection, it is undefined which of the documents will be updated.

    Exceptions

    \ArangoDBClient\Exception

    Returns

    boolean- always true, will throw if there is an error

    Get document(s) by specifying within

    within(mixed $collection, double $latitude, double $longitude, integer $radius, array $options = array()) : \ArangoDBClient\Cursor

    This will throw if the list cannot be fetched from the server

    deprecated use AQL queries instead

    Parameters

    $collection

    mixed
    • collection as string or object

    $latitude

    double
    • The latitude of the coordinate.

    $longitude

    double
    • The longitude of the coordinate.

    $radius

    integer
    • The maximal radius (in meters).

    $options

    array
    • optional array of options.

      Options are :

    • '_sanitize' - True to remove _id and _rev attributes from result documents. Defaults to false.
    • '_hiddenAttributes' - Set an array of hidden attributes for created documents.

      This is actually the same as setting hidden attributes using setHiddenAttributes() on a document.
      The difference is, that if you're returning a result set of documents, the getAll() is already called
      and the hidden attributes would not be applied to the attributes.

    • 'distance' - If given, the attribute key used to store the distance. (optional)
    • 'batchSize' - can optionally be used to tell the server to limit the number of results to be transferred in one batch
    • 'skip' - Optional, The number of documents to skip in the query.
    • 'limit' - Optional, The maximal amount of documents to return. 'skip' is applied before the limit restriction.

    Exceptions

    \ArangoDBClient\Exception

    Returns

    \ArangoDBClient\Cursor- documents matching the example [0...n]

    Add a transaction header to the array of headers in case this is a transactional operation

    addTransactionHeader(array $headers, mixed $collection) 
    Inherited

    Parameters

    $headers

    array
    • already existing headers

    $collection

    mixed
    • any type of collection (can be StreamingTransactionCollection or other)

    Return the connection object

    getConnection() : \ArangoDBClient\Connection
    Inherited

    Returns

    \ArangoDBClient\Connection- the connection object

    Return a connection option This is a convenience function that calls json_encode_wrapper on the connection

    getConnectionOption($optionName) : mixed
    Inherited

    Parameters

    $optionName

    • The option to return a value for

    Exceptions

    \ArangoDBClient\ClientException

    Returns

    mixed- the option's value

    Helper function that runs through the options given and includes them into the parameters array given.

    includeOptionsInBody(array $options, array $body, array $includeArray = array()) : array
    Inherited

    Only options that are set in $includeArray will be included. This is only for options that are to be sent to the ArangoDB server in a json body(like 'limit', 'skip', etc...) .

    Parameters

    $options

    array
    • The options array that holds the options to include in the parameters

    $body

    array
    • The array into which the options will be included.

    $includeArray

    array
    • The array that defines which options are allowed to be included, and what their default value is. for example: 'waitForSync'=>true

    Returns

    array$params - array of parameters for use in a url

    Return a json encoded string for the array passed.

    json_encode_wrapper(array $body) : string
    Inherited

    This is a convenience function that calls json_encode_wrapper on the connection

    Parameters

    $body

    array
    • The body to encode into json

    Exceptions

    \ArangoDBClient\ClientException

    Returns

    string- json string of the body that was passed

    Turn a value into a collection name

    makeCollection(mixed $value) : string
    Inherited

    Parameters

    $value

    mixed
    • document, collection or string

    Exceptions

    \ArangoDBClient\ClientException

    Returns

    string- collection name

    lazyCreateCollection()

    lazyCreateCollection($collection, $options) 

    Parameters

    $collection

    $options

     Properties

     

    Document class to use

    $_documentClass : string

    Default

    '\ArangoDBClient\Document'
     

    Edge class to use

    $_edgeClass : string

    Default

    '\ArangoDBClient\Edge'
     

    Connection object

    $_connection 

    Default

    param

     Constants

     

    documents array index

    ENTRY_DOCUMENTS = 'documents' 
     

    attribute parameter

    OPTION_ATTRIBUTE = 'attribute' 
     

    checksum option

    OPTION_CHECKSUM = 'checksum' 
     

    closed parameter

    OPTION_CLOSED = 'closed' 
     

    collection parameter

    OPTION_COLLECTION = 'collection' 
     

    count option

    OPTION_COUNT = 'count' 
     

    example parameter

    OPTION_CREATE_COLLECTION = 'createCollection' 
     

    distance parameter

    OPTION_DISTANCE = 'distance' 
     

    example parameter

    OPTION_EXAMPLE = 'example' 
     

    exclude system collections

    OPTION_EXCLUDE_SYSTEM = 'excludeSystem' 
     

    expireAfter option

    OPTION_EXPIRE_AFTER = 'expireAfter' 
     

    fields

    OPTION_FIELDS = 'fields' 
     

    figures option

    OPTION_FIGURES = 'figures' 
     

    fulltext index option

    OPTION_FULLTEXT_INDEX = 'fulltext' 
     

    geoJson option

    OPTION_GEOJSON = 'geoJson' 
     

    geo index option

    OPTION_GEO_INDEX = 'geo' 
     

    hash index option

    OPTION_HASH_INDEX = 'hash' 
     

    index parameter

    OPTION_INDEX = 'index' 
     

    inBackground option

    OPTION_IN_BACKGROUND = 'inBackground' 
     

    keys parameter

    OPTION_KEYS = 'keys' 
     

    latitude parameter

    OPTION_LATITUDE = 'latitude' 
     

    left parameter

    OPTION_LEFT = 'left' 
     

    limit parameter

    OPTION_LIMIT = 'limit' 
     

    load option

    OPTION_LOAD = 'load' 
     

    longitude parameter

    OPTION_LONGITUDE = 'longitude' 
     

    minLength option

    OPTION_MIN_LENGTH = 'minLength' 
     

    example parameter

    OPTION_NEW_VALUE = 'newValue' 
     

    persistent index option

    OPTION_PERSISTENT_INDEX = 'persistent' 
     

    properties option

    OPTION_PROPERTIES = 'properties' 
     

    query option

    OPTION_QUERY = 'query' 
     

    radius parameter

    OPTION_RADIUS = 'radius' 
     

    rename option

    OPTION_RENAME = 'rename' 
     

    responsible shard option

    OPTION_RESPONSIBLE_SHARD = 'responsibleShard' 
     

    revision option

    OPTION_REVISION = 'revision' 
     

    right parameter

    OPTION_RIGHT = 'right' 
     

    shards option

    OPTION_SHARDS = 'shards' 
     

    size option

    OPTION_SIZE = 'size' 
     

    skip parameter

    OPTION_SKIP = 'skip' 
     

    skiplist index option

    OPTION_SKIPLIST_INDEX = 'skiplist' 
     

    sparse index option

    OPTION_SPARSE = 'sparse' 
     

    stream parameter

    OPTION_STREAM = 'stream' 
     

    truncate option

    OPTION_TRUNCATE = 'truncate' 
     

    ttl index option

    OPTION_TTL_INDEX = 'ttl' 
     

    type

    OPTION_TYPE = 'type' 
     

    unique

    OPTION_UNIQUE = 'unique' 
     

    unload option

    OPTION_UNLOAD = 'unload'