public
mixed
|
#
create( mixed $collection, array $options = [] )
Creates a new collection on the server
Creates a new collection on the server
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
- collection object to be created on the server or a string with the name
- $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 .
- 'numberOfShards' - number of shards for the collection.
- 'shardKeys' - list of shard key attributes.
Returns
Throws
|
public
boolean
|
#
has( mixed $collection )
Check if a collection exists
Check if a collection exists
This will call self::get() internally and checks if there
was an exception thrown which represents an 404 request.
Parameters
- $collection
- collection id as a string or number
Returns
boolean
Throws
|
public
integer
|
#
count( mixed $collection )
Get the number of documents in a collection
Get the number of documents in a collection
This will throw if the collection cannot be fetched from the server
Parameters
- $collection
- collection id as a string or number
Returns
integer
- the number of documents in the collection
Throws
|
public
triagens\ArangoDb\Collection
|
#
get( mixed $collection )
Get information about a collection
Get information about a collection
This will throw if the collection cannot be fetched from the server
Parameters
- $collection
- collection id as a string or number
Returns
Throws
|
public
triagens\ArangoDb\Collection
|
#
getProperties( mixed $collection )
Get properties of a collection
Get properties of a collection
This will throw if the collection cannot be fetched from the server
Parameters
- $collection
- collection id as a string or number
Returns
Throws
|
public
array
|
#
figures( mixed $collection )
Get figures for a collection
Get figures for a collection
This will throw if the collection cannot be fetched from the server
Parameters
- $collection
- collection id as a string or number
Returns
array
- the figures for the collection
Throws
|
public
array
|
#
getChecksum( mixed $collectionId, boolean $withRevisions = false, boolean $withData = false )
Calculate a checksum of the collection.
Calculate a checksum of the collection.
Will calculate a checksum of the meta-data (keys and optionally revision ids)
and optionally the document data in the collection.
Parameters
- $collectionId
- collection id as a string or number
- $withRevisions
- optional boolean whether or not to include document revision ids
in the checksum calculation.
- $withData
- optional boolean whether or not to include document body data in the
checksum calculation.
Returns
array
- array containing keys "checksum" and "revision"
Throws
|
public
array
|
#
getRevision( mixed $collectionId )
Returns the Collections revision ID
Returns the Collections revision ID
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
- $collectionId
- collection id as a string or number
Returns
array
- containing a key revision
Throws
|
public
boolean
|
#
rename( mixed $collection, string $name )
Rename a collection
Parameters
- $collection
- collection id as string or number or collection object
- $name
Returns
boolean
- always true, will throw if there is an error
Throws
|
public
triagens\ArangoDb\HttpResponse
|
#
load( mixed $collection )
Load a collection into the server's memory
Load a collection into the server's memory
This will load the given collection into the server's memory.
Parameters
- $collection
- collection id as string or number or collection object
Returns
Throws
|
public
triagens\ArangoDb\HttpResponse
|
#
unload( mixed $collection )
Unload a collection from the server's memory
Unload a collection from the server's memory
This will unload the given collection from the server's memory.
Parameters
- $collection
- collection id as string or number or collection object
Returns
Throws
|
public
boolean
|
#
truncate( mixed $collection )
Truncate a collection
This will remove all documents from the collection but will leave the metadata and indexes intact.
Parameters
- $collection
- collection id as string or number or collection object
Returns
boolean
- always true, will throw if there is an error
Throws
|
public
boolean
|
#
drop( mixed $collection, array $options = [] )
Drop a collection
Parameters
- $collection
- collection id as string or number or collection object
- $options
- an array of options for the drop operation
Returns
boolean
- always true, will throw if there is an error
Throws
|
public
boolean
|
#
isValidCollectionId( $collectionId )
Checks if the collectionId given, is valid. Returns true if it is, or false if it is not.
Checks if the collectionId given, is valid. Returns true if it is, or false if it is not.
Parameters
Returns
boolean
|
public
array
|
#
getAllCollections( array $options = [] )
Get list of all available collections per default with the collection names as index.
Returns empty array if none are available.
Get list of all available collections per default with the collection names as index.
Returns empty array if none are available.
Parameters
- $options
- 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.
Returns
array
Throws
|
public
mixed
|
#
getCollectionId( mixed $collection )
Gets the collectionId from the given collectionObject or string/integer
Gets the collectionId from the given collectionObject or string/integer
Parameters
Returns
mixed
|
public
mixed
|
#
getCollectionName( mixed $collection )
Gets the collectionId from the given collectionObject or string/integer
Gets the collectionId from the given collectionObject or string/integer
Parameters
Returns
mixed
|
public
array
|
#
importFromFile( mixed $collectionId, mixed $importFileName, array $options = [] )
Import documents from a file
Import documents from a file
This will throw on all errors except insertion errors
Parameters
- $collectionId
- collection id as string or number
- $importFileName
- The filename that holds the import data.
- $options
- 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
Returns
array
- returns an array with the server's response data from the import command
Throws
|
public
array
|
#
import( $collection, string|array $importData, array $options = [] )
Import documents into a collection
Import documents into a collection
This will throw on all errors except insertion errors
Parameters
- $collection
- $collection - collection id as string or number
- $importData
- The data to import. This can be a string holding the data according to the type of import, or an array of documents
- $options
- 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
Returns
array
Throws
|
public
array
|
#
createHashIndex( string $collectionId, array $fields, boolean $unique = null, boolean $sparse = null )
Create a hash index
Parameters
- $collectionId
- $fields
- $unique
- whether the values in the index should be unique or not
- $sparse
- whether the index should be sparse
Returns
array
- server response of the created index
Throws
Link
|
public
array
|
#
createFulltextIndex( string $collectionId, array $fields, integer $minLength = null )
Create a fulltext index
Parameters
- $collectionId
- $fields
- $minLength
- the minimum length of words to index
Returns
array
- server response of the created index
Throws
Link
|
public
array
|
#
createSkipListIndex( string $collectionId, array $fields, boolean $unique = null, boolean $sparse = null )
Create a skip-list index
Parameters
- $collectionId
- $fields
- $unique
- whether the index is unique or not
- $sparse
- whether the index should be sparse
Returns
array
- server response of the created index
Throws
Link
|
public
array
|
#
createPersistentIndex( string $collectionId, array $fields, boolean $unique = null, boolean $sparse = null )
Create a persistent index
Create a persistent index
Parameters
- $collectionId
- $fields
- $unique
- whether the index is unique or not
- $sparse
- whether the index should be sparse
Returns
array
- server response of the created index
Throws
Link
|
public
array
|
#
createGeoIndex( string $collectionId, array $fields, boolean $geoJson = null, boolean $constraint = null, boolean $ignoreNull = null )
Create a geo index
Parameters
- $collectionId
- $fields
- $geoJson
- whether to use geoJson or not
- $constraint
- whether this is a constraint or not
- $ignoreNull
Returns
array
- server response of the created index
Throws
Link
|
public
array
|
#
index( mixed $collectionId, string $type = '', array $attributes = [], boolean $unique = false, array $indexOptions = [] )
Creates an index on a collection on the server
Creates an index on a collection on the server
This will create an index on the collection on the server and return its id
This will throw if the index cannot be created
Parameters
- $collectionId
- The id of the collection where the index is to be created
- $type
- index type: hash, skiplist, geo, fulltext, or persistent
- $attributes
- an array of attributes that can be defined like array('a') or array('a', 'b.c')
- $unique
- true/false to create a unique index
- $indexOptions
- an associative array of options for the index like array('geoJson' => true, 'sparse' => false)
Returns
array
- server response of the created index
Throws
|
public
array
|
#
getIndex( string $collection, string $indexId )
Get the information about an index in a collection
Get the information about an index in a collection
Parameters
Returns
array
Throws
|
public
array
|
#
getIndexes( mixed $collectionId )
Get indexes of a collection
Get indexes of a collection
This will throw if the collection cannot be fetched from the server
Parameters
- $collectionId
- collection id as a string or number
Returns
array $data - the indexes result-set from the server
Throws
|
public
boolean
|
#
dropIndex( mixed $indexHandle )
Drop an index
Parameters
- $indexHandle
- index handle (collection name / index id)
Returns
boolean
- always true, will throw if there is an error
Throws
|
public
triagens\ArangoDb\Document
|
#
any( mixed $collectionId )
Get a random document from the collection.
Get a random document from the collection.
This will throw if the document cannot be fetched from the server
Parameters
- $collectionId
- collection id as string or number
Returns
Throws
Since
1.2
|
public
triagens\ArangoDb\Cursor
|
#
all( mixed $collectionId, array $options = [] )
Returns all documents of a collection
Returns all documents of a collection
Parameters
- $collectionId
- collection id as string or number
- $options
- 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.
Returns
Throws
|
public
array
|
#
getAllIds( mixed $collection )
Get the list of all documents' ids from a collection
Get the list of all documents' ids from a collection
This will throw if the list cannot be fetched from the server
Parameters
- $collection
- collection id as string or number
Returns
array
- ids of documents in the collection
Throws
|
public
cursor
|
#
byExample( mixed $collectionId, mixed $document, array $options = [] )
Get document(s) by specifying an example
Get document(s) by specifying an example
This will throw if the list cannot be fetched from the server
Parameters
- $collectionId
- collection id as string or number
- $document
- the example document as a Document object or an array
- $options
- 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.
Returns
cursor
- Returns a cursor containing the result
Throws
|
public
triagens\ArangoDb\Document
|
#
firstExample( mixed $collectionId, mixed $document, array $options = [] )
Get the first document matching a given example.
Get the first document matching a given example.
This will throw if the document cannot be fetched from the server
Parameters
- $collectionId
- collection id as string or number
- $document
- the example document as a Document object or an array
- $options
- 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.
Returns
Throws
Since
1.2
|
public
cursor
|
#
fulltext( mixed $collection, mixed $attribute, mixed $query, array $options = [] )
Get document(s) by a fulltext query
Get document(s) by a fulltext query
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.
Parameters
- $collection
- collection id as string or number
- $attribute
- The attribute that contains the texts.
- $query
- $options
- 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.
Returns
cursor
- Returns a cursor containing the result
Throws
|
public
boolean
|
#
updateByExample( mixed $collectionId, mixed $example, mixed $newValue, array $options = [] )
Update document(s) matching a given example
Update document(s) matching a given example
This will update the document(s) on the server
This will throw if the document cannot be updated
Parameters
- $collectionId
- collection id as string or number
- $example
- the example document as a Document object or an array
- $newValue
- patch document or array which contains the attributes and values to be updated
- $options
- 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.
Returns
boolean
- always true, will throw if there is an error
Throws
Since
1.2
|
public
boolean
|
#
replaceByExample( mixed $collectionId, mixed $example, mixed $newValue, array $options = [] )
Replace document(s) matching a given example
Replace document(s) matching a given example
This will replace the document(s) on the server
This will throw if the document cannot be replaced
Parameters
- $collectionId
- collection id as string or number
- $example
- the example document as a Document object or an array
- $newValue
- patch document or array which contains the attributes and values to be replaced
- $options
- 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.
Returns
boolean
- always true, will throw if there is an error
Throws
Since
1.2
|
public
integer
|
#
removeByExample( mixed $collectionId, mixed $document, array $options = [] )
Remove document(s) by specifying an example
Remove document(s) by specifying an example
This will throw on any error
Parameters
- $collectionId
- collection id as string or number
- $document
- the example document as a Document object or an array
- $options
- 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.
<li>'limit' - Optional, The maximal amount of documents to return. 'skip' is applied before the limit restriction.</li>
Returns
integer
- number of documents that were deleted
Throws
Since
1.2
|
public
array
|
#
removeByKeys( mixed $collectionId, array $keys, array $options = [] )
Remove document(s) by specifying an array of keys
Remove document(s) by specifying an array of keys
This will throw on any error
Parameters
- $collectionId
- collection id as string or number
- $keys
- $options
- 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.
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
Throws
Since
2.6
|
public
array
|
#
lookupByKeys( mixed $collectionId, array $keys, array $options = [] )
Bulk lookup documents by specifying an array of keys
Bulk lookup documents by specifying an array of keys
This will throw on any error
Parameters
- $collectionId
- collection id as string or number
- $keys
- $options
- 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.
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.
Throws
Since
2.6
|
public
triagens\ArangoDb\Cursor
|
#
range( mixed $collectionId, string $attribute, mixed $left, mixed $right, array $options = [] )
Get document(s) by specifying range
Get document(s) by specifying range
This will throw if the list cannot be fetched from the server
Parameters
- $collectionId
- collection id as string or number
- $attribute
- the attribute path , like 'a', 'a.b', etc...
- $left
- $right
- $options
- 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.
Returns
Throws
|
public
triagens\ArangoDb\Cursor
|
#
near( mixed $collectionId, float $latitude, float $longitude, array $options = [] )
Get document(s) by specifying near
Get document(s) by specifying near
This will throw if the list cannot be fetched from the server
Parameters
- $collectionId
- collection id as string or number
- $latitude
- The latitude of the coordinate.
- $longitude
- The longitude of the coordinate.
- $options
- 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.
Returns
Throws
|
public
triagens\ArangoDb\Cursor
|
#
within( mixed $collectionId, float $latitude, float $longitude, integer $radius, array $options = [] )
Get document(s) by specifying within
Get document(s) by specifying within
This will throw if the list cannot be fetched from the server
Parameters
- $collectionId
- collection id as string or number
- $latitude
- The latitude of the coordinate.
- $longitude
- The longitude of the coordinate.
- $radius
- The maximal radius (in meters).
- $options
- 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.
Returns
Throws
|