ArangoDB v3.4 reached End of Life (EOL) and is no longer supported.
This documentation is outdated. Please see the most recent version here: Latest Docs
Simple queries
These functions implement the HTTP API for simple queries.
collection.all
async collection.all([opts]): Cursor
Performs a query to fetch all documents in the collection. Returns a new Cursor instance for the query results.
Arguments
-
opts:
Object
(optional)For information on the possible options see the HTTP API for returning all documents.
collection.any
async collection.any(): Object
Fetches a document from the collection at random.
collection.first
async collection.first([opts]): Array<Object>
Performs a query to fetch the first documents in the collection. Returns an array of the matching documents.
This method is not available when targeting ArangoDB 3.0 or later, see Compatibility.
Arguments
-
opts:
Object
(optional)If opts is a number it is treated as opts.count.
collection.last
async collection.last([opts]): Array<Object>
Performs a query to fetch the last documents in the collection. Returns an array of the matching documents.
This method is not available when targeting ArangoDB 3.0 or later, see Compatibility.
Arguments
-
opts:
Object
(optional)If opts is a number it is treated as opts.count.
collection.byExample
async collection.byExample(example, [opts]): Cursor
Performs a query to fetch all documents in the collection matching the given example. Returns a new Cursor instance for the query results.
Arguments
-
example: Object
An object representing an example for documents to be matched against.
-
opts: Object (optional)
For information on the possible options see the HTTP API for fetching documents by example.
collection.firstExample
async collection.firstExample(example): Object
Fetches the first document in the collection matching the given example.
Arguments
-
example: Object
An object representing an example for documents to be matched against.
collection.removeByExample
async collection.removeByExample(example, [opts]): Object
Removes all documents in the collection matching the given example.
Arguments
-
example: Object
An object representing an example for documents to be matched against.
-
opts: Object (optional)
For information on the possible options see the HTTP API for removing documents by example.
collection.replaceByExample
async collection.replaceByExample(example, newValue, [opts]): Object
Replaces all documents in the collection matching the given example with the given newValue.
Arguments
-
example: Object
An object representing an example for documents to be matched against.
-
newValue: Object
The new value to replace matching documents with.
-
opts: Object (optional)
For information on the possible options see the HTTP API for replacing documents by example.
collection.updateByExample
async collection.updateByExample(example, newValue, [opts]): Object
Updates (patches) all documents in the collection matching the given example with the given newValue.
Arguments
-
example: Object
An object representing an example for documents to be matched against.
-
newValue: Object
The new value to update matching documents with.
-
opts: Object (optional)
For information on the possible options see the HTTP API for updating documents by example.
collection.lookupByKeys
async collection.lookupByKeys(keys): Array<Object>
Fetches the documents with the given keys from the collection. Returns an array of the matching documents.
Arguments
-
keys: Array
An array of document keys to look up.
collection.removeByKeys
async collection.removeByKeys(keys, [opts]): Object
Deletes the documents with the given keys from the collection.
Arguments
-
keys: Array
An array of document keys to delete.
-
opts: Object (optional)
For information on the possible options see the HTTP API for removing documents by keys.
collection.fulltext
async collection.fulltext(fieldName, query, [opts]): Cursor
Performs a fulltext query in the given fieldName on the collection.
Arguments
-
fieldName: String
Name of the field to search on documents in the collection.
-
query: String
Fulltext query string to search for.
-
opts: Object (optional)
For information on the possible options see the HTTP API for fulltext queries.