///
/**
* ```ts
* import type {
* DocumentCollection,
* EdgeCollection,
* } from "arangojs/collection";
* ```
*
* The "collection" module provides collection related types and interfaces
* for TypeScript.
*
* @packageDocumentation
*/
import { ArangoResponseMetadata } from "./connection";
import { ArrayCursor } from "./cursor";
import { Database } from "./database";
import { Document, DocumentData, DocumentMetadata, DocumentSelector, Edge, EdgeData, ObjectWithKey, Patch } from "./documents";
import { EnsureFulltextIndexOptions, EnsureGeoIndexOptions, EnsureHashIndexOptions, EnsurePersistentIndexOptions, EnsureSkiplistIndexOptions, EnsureTtlIndexOptions, FulltextIndex, GeoIndex, HashIndex, Index, IndexSelector, PersistentIndex, SkiplistIndex, TtlIndex } from "./indexes";
import { Blob } from "./lib/blob";
/**
* Indicates whether the given value represents an {@link ArangoCollection}.
*
* @param collection - A value that might be a collection.
*/
export declare function isArangoCollection(collection: any): collection is ArangoCollection;
/**
* Coerces the given collection name or {@link ArangoCollection} object to
* a string representing the collection name.
*
* @param collection - Collection name or {@link ArangoCollection} object.
*/
export declare function collectionToString(collection: string | ArangoCollection): string;
/**
* A marker interface identifying objects that can be used in AQL template
* strings to create references to ArangoDB collections.
*
* See {@link aql}.
*/
export interface ArangoCollection {
/**
* @internal
*
* Indicates that this object represents an ArangoDB collection.
*/
readonly isArangoCollection: true;
/**
* Name of the collection.
*/
readonly name: string;
}
/**
* Integer values indicating the collection type.
*/
export declare enum CollectionType {
DOCUMENT_COLLECTION = 2,
EDGE_COLLECTION = 3
}
/**
* Integer values indicating the collection loading status.
*/
export declare enum CollectionStatus {
NEWBORN = 1,
UNLOADED = 2,
LOADED = 3,
UNLOADING = 4,
DELETED = 5,
LOADING = 6
}
/**
* Type of key generator.
*/
export declare type KeyGenerator = "traditional" | "autoincrement" | "uuid" | "padded";
/**
* Strategy for sharding a collection.
*/
export declare type ShardingStrategy = "hash" | "enterprise-hash-smart-edge" | "community-compat" | "enterprise-compat" | "enterprise-smart-edge-compat";
/**
* Type of document reference.
*
* See {@link DocumentCollection.list} and {@link EdgeCollection.list}.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*/
export declare type SimpleQueryListType = "id" | "key" | "path";
/**
* When a validation should be applied.
*
* * `"none"`: No validation.
* * `"new"`: Newly inserted documents are validated.
* * `"moderate"`: New and modified documents are validated unless the modified
* document was already invalid.
* * `"strict"`: New and modified documents are always validated.
*/
export declare type ValidationLevel = "none" | "new" | "moderate" | "strict";
/**
* General information about a collection.
*/
export declare type CollectionMetadata = {
/**
* Collection name.
*/
name: string;
/**
* A globally unique identifier for this collection.
*/
globallyUniqueId: string;
/**
* An integer indicating the collection loading status.
*/
status: CollectionStatus;
/**
* An integer indicating the collection type.
*/
type: CollectionType;
/**
* @internal
*
* Whether the collection is a system collection.
*/
isSystem: boolean;
};
/**
* An object defining the collection's key generation.
*/
export declare type CollectionKeyProperties = {
/**
* Type of key generator to use.
*/
type: KeyGenerator;
/**
* Whether documents can be created with a user-specified `_key` attribute.
*/
allowUserKeys: boolean;
/**
* (Autoincrement only.) How many steps to increment the key each time.
*/
increment?: number;
/**
* (Autoincrement only.) Initial offset for the key.
*/
offset?: number;
/**
* Most recent key that has been generated.
*/
lastValue: number;
};
/**
* Properties for validating documents in a collection.
*/
export declare type SchemaProperties = {
/**
* Type of document validation.
*/
type: "json";
/**
* JSON Schema description of the validation schema for documents.
*/
rule: any;
/**
* When validation should be applied.
*/
level: ValidationLevel;
/**
* Message to be used if validation fails.
*/
message: string;
};
/**
* An object defining the properties of a collection.
*/
export declare type CollectionProperties = {
/**
* A human-readable representation of the collection loading status.
*/
statusString: string;
/**
* Whether data should be synchronized to disk before returning from
* a document create, update, replace or removal operation.
*/
waitForSync: boolean;
/**
* An object defining the collection's key generation.
*/
keyOptions: CollectionKeyProperties;
/**
* Properties for validating documents in the collection.
*/
schema: SchemaProperties | null;
/**
* (Cluster only.) Write concern for this collection.
*/
writeConcern: number;
/**
* (Cluster only.) Write concern for this collection.
*
* @deprecated Renamed to `writeConcern` in ArangoDB 3.6.
*/
minReplicationFactor?: number;
/**
* (Cluster only.) Number of shards of this collection.
*/
numberOfShards?: number;
/**
* (Cluster only.) Keys of this collection that will be used for
* sharding.
*/
shardKeys?: string[];
/**
* (Cluster only.) Replication factor of the collection.
*/
replicationFactor?: number;
/**
* (Cluster only.) Sharding strategy of the collection.
*/
shardingStrategy?: ShardingStrategy;
/**
* (MMFiles only.) Whether the collection will be compacted.
*/
doCompact?: boolean;
/**
* (MMFiles only.) Maximum size for each journal or datafile in bytes.
*/
journalSize?: number;
/**
* (MMFiles only.) Number of buckets into which indexes using hash tables are
* split.
*/
indexBuckets?: number;
/**
* (MMFiles only.) If set to `true`, the collection will only be kept
* in-memory and discarded when unloaded, resulting in full data loss.
*/
isVolatile?: boolean;
/**
* (Enterprise Edition cluster only.) If set to a collection name, sharding
* of the new collection will follow the rules for that collection. As long
* as the new collection exists, the indicated collection can not be dropped.
*/
distributeShardsLike?: string;
/**
* (Enterprise Edition cluster only.) Attribute containing the shard key
* value of the referred-to smart join collection.
*/
smartJoinAttribute?: string;
};
/**
* Options for validating collection documents.
*/
export declare type SchemaOptions = {
/**
* JSON Schema description of the validation schema for documents.
*/
rule: any;
/**
* When validation should be applied.
*
* Default: `"strict"`
*/
level?: ValidationLevel;
/**
* Message to be used if validation fails.
*/
message?: string;
};
/**
* Options for setting a collection's properties.
*
* See {@link DocumentCollection.properties} and {@link EdgeCollection.properties}.
*/
export declare type CollectionPropertiesOptions = {
/**
* Whether data should be synchronized to disk before returning from
* a document create, update, replace or removal operation.
*/
waitForSync?: boolean;
/**
* Options for validating documents in this collection.
*/
schema?: SchemaOptions;
/**
* (MMFiles only.) Maximum size for each journal or datafile in bytes.
*
* Must be a number greater than or equal to `1048576` (1 MiB).
*/
journalSize?: number;
};
/**
* Options for retrieving a collection checksum.
*/
export declare type CollectionChecksumOptions = {
/**
* If set to `true`, revision IDs will be included in the calculation
* of the checksum.
*
* Default: `false`
*/
withRevisions?: boolean;
/**
* If set to `true`, document data will be included in the calculation
* of the checksum.
*
* Default: `false`
*/
withData?: boolean;
};
/**
* Options for dropping collections.
*/
export declare type CollectionDropOptions = {
/**
* Whether the collection is a system collection. If the collection is a
* system collection, this option must be set to `true` or ArangoDB will
* refuse to drop the collection.
*
* Default: `false`
*/
isSystem?: boolean;
};
/**
* An object defining the collection's key generation.
*/
export declare type CollectionKeyOptions = {
/**
* Type of key generator to use.
*/
type?: KeyGenerator;
/**
* Unless set to `false`, documents can be created with a user-specified
* `_key` attribute.
*
* Default: `true`
*/
allowUserKeys?: boolean;
/**
* (Autoincrement only.) How many steps to increment the key each time.
*/
increment?: number;
/**
* (Autoincrement only.) Initial offset for the key.
*/
offset?: number;
};
/**
* Options for creating a collection.
*
* See {@link Database.createCollection}, {@link Database.createEdgeCollection}
* and {@link DocumentCollection.create} or {@link EdgeCollection.create}.
*/
export declare type CreateCollectionOptions = {
/**
* If set to `true`, data will be synchronized to disk before returning from
* a document create, update, replace or removal operation.
*
* Default: `false`
*/
waitForSync?: boolean;
/**
* @internal
*
* Whether the collection should be created as a system collection.
*
* Default: `false`
*/
isSystem?: boolean;
/**
* An object defining the collection's key generation.
*/
keyOptions?: CollectionKeyOptions;
/**
* Options for validating documents in the collection.
*/
schema?: SchemaOptions;
/**
* (Cluster only.) Unless set to `false`, the server will wait for all
* replicas to create the collection before returning.
*
* Default: `true`
*/
waitForSyncReplication?: boolean;
/**
* (Cluster only.) Unless set to `false`, the server will check whether
* enough replicas are available at creation time and bail out otherwise.
*
* Default: `true`
*/
enforceReplicationFactor?: boolean;
/**
* (Cluster only.) Number of shards to distribute the collection across.
*
* Default: `1`
*/
numberOfShards?: number;
/**
* (Cluster only.) Document attributes to use to determine the target shard
* for each document.
*
* Default: `["_key"]`
*/
shardKeys?: string[];
/**
* (Cluster only.) How many copies of each document should be kept in the
* cluster.
*
* Default: `1`
*/
replicationFactor?: number;
/**
* (Cluster only.) Write concern for this collection.
*/
writeConcern?: number;
/**
* (Cluster only.) Write concern for this collection.
*
* @deprecated Renamed to `writeConcern` in ArangoDB 3.6.
*/
minReplicationFactor?: number;
/**
* (Cluster only.) Sharding strategy to use.
*/
shardingStrategy?: ShardingStrategy;
/**
* (MMFiles only.) Number of buckets into which indexes using hash tables are
* split.
*
* Must be a power of 2 and less than or equal to `1024`.
*
* Default: `16`
*/
indexBuckets?: number;
/**
* (MMFiles only.) Whether the collection will be compacted.
*
* Default: `true`
*/
doCompact?: boolean;
/**
* (MMFiles only.) Maximum size for each journal or datafile in bytes.
*
* Must be a number greater than or equal to `1048576` (1 MiB).
*/
journalSize?: number;
/**
* (MMFiles only.) If set to `true`, the collection will only be kept
* in-memory and discarded when unloaded, resulting in full data loss.
*
* Default: `false`
*/
isVolatile?: boolean;
/**
* (Enterprise Edition cluster only.) If set to a collection name, sharding
* of the new collection will follow the rules for that collection. As long
* as the new collection exists, the indicated collection can not be dropped.
*/
distributeShardsLike?: string;
/**
* (Enterprise Edition cluster only.) Attribute containing the shard key
* value of the referred-to smart join collection.
*/
smartJoinAttribute?: string;
};
/**
* Options for retrieving a document from a collection.
*/
export declare type CollectionReadOptions = {
/**
* If set to `true`, `null` is returned instead of an exception being thrown
* if the document does not exist.
*/
graceful?: boolean;
/**
* If set to `true`, the request will explicitly permit ArangoDB to return a
* potentially dirty or stale result and arangojs will load balance the
* request without distinguishing between leaders and followers.
*/
allowDirtyRead?: boolean;
};
/**
* Options for retrieving multiple documents from a collection.
*/
export declare type CollectionBatchReadOptions = {
/**
* If set to `true`, the request will explicitly permit ArangoDB to return a
* potentially dirty or stale result and arangojs will load balance the
* request without distinguishing between leaders and followers.
*/
allowDirtyRead?: boolean;
};
/**
* Options for inserting a new document into a collection.
*/
export declare type CollectionInsertOptions = {
/**
* If set to `true`, data will be synchronized to disk before returning.
*
* Default: `false`
*/
waitForSync?: boolean;
/**
* If set to `true`, no data will be returned by the server. This option can
* be used to reduce network traffic.
*
* Default: `false`
*/
silent?: boolean;
/**
* If set to `true`, the complete new document will be returned as the `new`
* property on the result object. Has no effect if `silent` is set to `true`.
*
* Default: `false`
*/
returnNew?: boolean;
/**
* If set to `true`, a document with the same `_key` or `_id` already
* existing will be overwritten instead of resulting in an exception.
*
* @deprecated This option has been deprecated in ArangoDB 3.7 and replaced
* with the `overwriteMode` option.
*/
overwrite?: boolean;
/**
* Defines what should happen if a document with the same `_key` or `_id`
* already exists, instead of throwing an exception.
*
* Default: `"conflict"
*/
overwriteMode?: "ignore" | "update" | "replace" | "conflict";
};
/**
* Options for replacing an existing document in a collection.
*/
export declare type CollectionReplaceOptions = {
/**
* If set to `true`, data will be synchronized to disk before returning.
*
* Default: `false`
*/
waitForSync?: boolean;
/**
* If set to `true`, no data will be returned by the server. This option can
* be used to reduce network traffic.
*
* Default: `false`
*/
silent?: boolean;
/**
* If set to `true`, the complete new document will be returned as the `new`
* property on the result object. Has no effect if `silent` is set to `true`.
*
* Default: `false`
*/
returnNew?: boolean;
/**
* If set to `false`, the existing document will only be modified if its
* `_rev` property matches the same property on the new data.
*
* Default: `true`
*/
ignoreRevs?: boolean;
/**
* If set to `true`, the complete old document will be returned as the `old`
* property on the result object. Has no effect if `silent` is set to `true`.
*
* Default: `false`
*/
returnOld?: boolean;
};
/**
* Options for updating a document in a collection.
*/
export declare type CollectionUpdateOptions = {
/**
* If set to `true`, data will be synchronized to disk before returning.
*
* Default: `false`
*/
waitForSync?: boolean;
/**
* If set to `true`, no data will be returned by the server. This option can
* be used to reduce network traffic.
*
* Default: `false`
*/
silent?: boolean;
/**
* If set to `true`, the complete new document will be returned as the `new`
* property on the result object. Has no effect if `silent` is set to `true`.
*
* Default: `false`
*/
returnNew?: boolean;
/**
* If set to `false`, the existing document will only be modified if its
* `_rev` property matches the same property on the new data.
*
* Default: `true`
*/
ignoreRevs?: boolean;
/**
* If set to `true`, the complete old document will be returned as the `old`
* property on the result object. Has no effect if `silent` is set to `true`.
*
* Default: `false`
*/
returnOld?: boolean;
/**
* If set to `false`, properties with a value of `null` will be removed from
* the new document.
*
* Default: `true`
*/
keepNull?: boolean;
/**
* If set to `false`, object properties that already exist in the old
* document will be overwritten rather than merged. This does not affect
* arrays.
*
* Default: `true`
*/
mergeObjects?: boolean;
};
/**
* Options for removing a document from a collection.
*/
export declare type CollectionRemoveOptions = {
/**
* If set to `true`, changes will be synchronized to disk before returning.
*
* Default: `false`
*/
waitForSync?: boolean;
/**
* If set to `true`, the complete old document will be returned as the `old`
* property on the result object. Has no effect if `silent` is set to `true`.
*
* Default: `false`
*/
returnOld?: boolean;
/**
* If set to `true`, no data will be returned by the server. This option can
* be used to reduce network traffic.
*
* Default: `false`
*/
silent?: boolean;
};
/**
* Options for bulk importing documents into a collection.
*/
export declare type CollectionImportOptions = {
/**
* (Edge collections only.) Prefix to prepend to `_from` attribute values.
*/
fromPrefix?: string;
/**
* (Edge collections only.) Prefix to prepend to `_to` attribute values.
*/
toPrefix?: string;
/**
* If set to `true`, the collection is truncated before the data is imported.
*
* Default: `false`
*/
overwrite?: boolean;
/**
* Whether to wait for the documents to have been synced to disk.
*/
waitForSync?: boolean;
/**
* Controls behavior when a unique constraint is violated on the document key.
*
* * `"error"`: the document will not be imported.
* * `"update`: the document will be merged into the existing document.
* * `"replace"`: the document will replace the existing document.
* * `"ignore"`: the document will not be imported and the unique constraint
* error will be ignored.
*
* Default: `"error"`
*/
onDuplicate?: "error" | "update" | "replace" | "ignore";
/**
* If set to `true`, the import will abort if any error occurs.
*/
complete?: boolean;
/**
* Whether the response should contain additional details about documents
* that could not be imported.
*/
details?: boolean;
};
/**
* Options for retrieving documents by example.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*/
export declare type SimpleQueryByExampleOptions = {
/**
* Number of documents to skip in the query.
*/
skip?: number;
/**
* Maximum number of documents to return.
*/
limit?: number;
/**
* Number of result values to be transferred by the server in each
* network roundtrip (or "batch").
*
* Must be greater than zero.
*
* See also {@link QueryOptions}.
*/
batchSize?: number;
/**
* Time-to-live for the cursor in seconds. The cursor results may be
* garbage collected by ArangoDB after this much time has passed.
*
* See also {@link QueryOptions}.
*/
ttl?: number;
};
/**
* Options for retrieving all documents in a collection.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*/
export declare type SimpleQueryAllOptions = {
/**
* Number of documents to skip in the query.
*/
skip?: number;
/**
* Maximum number of documents to return.
*/
limit?: number;
/**
* Number of result values to be transferred by the server in each
* network roundtrip (or "batch").
*
* Must be greater than zero.
*
* See also {@link QueryOptions}.
*/
batchSize?: number;
/**
* Time-to-live for the cursor in seconds. The cursor results may be
* garbage collected by ArangoDB after this much time has passed.
*
* See also {@link QueryOptions}.
*/
ttl?: number;
/**
* If set to `true`, the query will be executed as a streaming query.
*
* See also {@link QueryOptions}.
*/
stream?: boolean;
};
/**
* Options for updating documents by example.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*/
export declare type SimpleQueryUpdateByExampleOptions = {
/**
* If set to `false`, properties with a value of `null` will be removed from
* the new document.
*
* Default: `true`
*/
keepNull?: boolean;
/**
* If set to `true`, the request will wait until all modifications have been
* synchronized to disk before returning successfully.
*
* Default: `false`
*/
waitForSync?: boolean;
/**
* Maximum number of documents to return.
*/
limit?: number;
/**
* If set to `false`, object properties that already exist in the old
* document will be overwritten rather than merged. This does not affect
* arrays.
*
* Default: `true`
*/
mergeObjects?: boolean;
};
/**
* Options for removing documents by example.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*/
export declare type SimpleQueryRemoveByExampleOptions = {
/**
* If set to `true`, the request will wait until all modifications have been
* synchronized to disk before returning successfully.
*
* Default: `false`
*/
waitForSync?: boolean;
/**
* Maximum number of documents to return.
*/
limit?: number;
};
/**
* Options for replacing documents by example.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*/
export declare type SimpleQueryReplaceByExampleOptions = SimpleQueryRemoveByExampleOptions;
/**
* Options for removing documents by keys.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*/
export declare type SimpleQueryRemoveByKeysOptions = {
/**
* If set to `true`, the complete old document will be returned as the `old`
* property on the result object. Has no effect if `silent` is set to `true`.
*
* Default: `false`
*/
returnOld?: boolean;
/**
* If set to `true`, no data will be returned by the server. This option can
* be used to reduce network traffic.
*
* Default: `false`
*/
silent?: boolean;
/**
* If set to `true`, the request will wait until all modifications have been
* synchronized to disk before returning successfully.
*
* Default: `false`
*/
waitForSync?: boolean;
};
/**
* Options for performing a fulltext query.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*/
export declare type SimpleQueryFulltextOptions = {
/**
* Unique identifier of the fulltext index to use to perform the query.
*/
index?: string;
/**
* Maximum number of documents to return.
*/
limit?: number;
/**
* Number of documents to skip in the query.
*/
skip?: number;
};
/**
* Options for performing a graph traversal.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*/
export declare type TraversalOptions = {
/**
* A string evaluating to the body of a JavaScript function to be executed
* on the server to initialize the traversal result object.
*
* The code has access to two variables: `config`, `result`.
* The code may modify the `result` object.
*
* **Note**: This code will be evaluated and executed on the
* server inside ArangoDB's embedded JavaScript environment and can not
* access any other variables.
*
* See the official ArangoDB documentation for
* {@link https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html | the JavaScript `@arangodb` module}
* for information about accessing the database from within ArangoDB's
* server-side JavaScript environment.
*/
init?: string;
/**
* A string evaluating to the body of a JavaScript function to be executed
* on the server to filter nodes.
*
* The code has access to three variables: `config`, `vertex`, `path`.
* The code may include a return statement for the following values:
*
* * `"exclude"`: The vertex will not be visited.
* * `"prune"`: The edges of the vertex will not be followed.
* * `""` or `undefined`: The vertex will be visited and its edges followed.
* * an array including any of the above values.
*
* **Note**: This code will be evaluated and executed on the
* server inside ArangoDB's embedded JavaScript environment and can not
* access any other variables.
*
* See the official ArangoDB documentation for
* {@link https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html | the JavaScript `@arangodb` module}
* for information about accessing the database from within ArangoDB's
* server-side JavaScript environment.
*/
filter?: string;
/**
* A string evaluating to the body of a JavaScript function to be executed
* on the server to sort edges if `expander` is not set.
*
* The code has access to two variables representing edges: `l`, `r`.
* The code must return `-1` if `l < r`, `1` if `l > r` or `0` if both
* values are equal.
*
* **Note**: This code will be evaluated and executed on the
* server inside ArangoDB's embedded JavaScript environment and can not
* access any other variables.
*
* See the official ArangoDB documentation for
* {@link https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html | the JavaScript `@arangodb` module}
* for information about accessing the database from within ArangoDB's
* server-side JavaScript environment.
*/
sort?: string;
/**
* A string evaluating to the body of a JavaScript function to be executed
* on the server when a node is visited.
*
* The code has access to five variables: `config`, `result`, `vertex`,
* `path`, `connected`.
* The code may modify the `result` object.
*
* **Note**: This code will be evaluated and executed on the
* server inside ArangoDB's embedded JavaScript environment and can not
* access any other variables.
*
* See the official ArangoDB documentation for
* {@link https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html | the JavaScript `@arangodb` module}
* for information about accessing the database from within ArangoDB's
* server-side JavaScript environment.
*/
visitor?: string;
/**
* A string evaluating to the body of a JavaScript function to be executed
* on the server to use when `direction` is not set.
*
* The code has access to three variables: `config`, `vertex`, `path`.
* The code must return an array of objects with `edge` and `vertex`
* attributes representing the connections for the vertex.
*
* **Note**: This code will be evaluated and executed on the
* server inside ArangoDB's embedded JavaScript environment and can not
* access any other variables.
*
* See the official ArangoDB documentation for
* {@link https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html | the JavaScript `@arangodb` module}
* for information about accessing the database from within ArangoDB's
* server-side JavaScript environment.
*/
expander?: string;
/**
* Direction of the traversal, relative to the starting vertex if `expander`
* is not set.
*/
direction?: "inbound" | "outbound" | "any";
/**
* Item iteration order.
*/
itemOrder?: "forward" | "backward";
/**
* Traversal strategy.
*/
strategy?: "depthfirst" | "breadthfirst";
/**
* Traversal order.
*/
order?: "preorder" | "postorder" | "preorder-expander";
/**
* Specifies uniqueness for vertices and edges.
*/
uniqueness?: {
/**
* Uniqueness for vertices.
*/
vertices?: "none" | "global" | "path";
/**
* Uniqueness for edges.
*/
edges?: "none" | "global" | "path";
};
/**
* If specified, only nodes in at least this depth will be visited.
*/
minDepth?: number;
/**
* If specified, only nodes in at most this depth will be visited.
*/
maxDepth?: number;
/**
* Maximum number of iterations before a traversal is aborted because of a
* potential endless loop.
*/
maxIterations?: number;
};
/**
* Result of a collection bulk import.
*/
export declare type CollectionImportResult = {
/**
* Whether the import failed.
*/
error: false;
/**
* Number of new documents imported.
*/
created: number;
/**
* Number of documents that failed with an error.
*/
errors: number;
/**
* Number of empty documents.
*/
empty: number;
/**
* Number of documents updated.
*/
updated: number;
/**
* Number of documents that failed with an error that is ignored.
*/
ignored: number;
/**
* Additional details about any errors encountered during the import.
*/
details?: string[];
};
/**
* Result of retrieving edges in a collection.
*/
export declare type CollectionEdgesResult = any> = {
edges: Edge[];
stats: {
scannedIndex: number;
filtered: number;
};
};
/**
* Result of removing documents by an example.
*
* See {@link DocumentCollection.removeByExample} and {@link EdgeCollection.removeByExample}.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*/
export declare type SimpleQueryRemoveByExampleResult = {
/**
* Number of documents removed.
*/
deleted: number;
};
/**
* Result of replacing documents by an example.
*
* See {@link DocumentCollection.replaceByExample} and {@link EdgeCollection.replaceByExample}.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*/
export declare type SimpleQueryReplaceByExampleResult = {
/**
* Number of documents replaced.
*/
replaced: number;
};
/**
* Result of updating documents by an example.
*
* See {@link DocumentCollection.updateByExample} and {@link EdgeCollection.updateByExample}.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*/
export declare type SimpleQueryUpdateByExampleResult = {
/**
* Number of documents updated.
*/
updated: number;
};
/**
* Result of removing documents by keys.
*
* See {@link DocumentCollection.removeByKeys} and {@link EdgeCollection.removeByKeys}.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*/
export declare type SimpleQueryRemoveByKeysResult = any> = {
/**
* Number of documents removed.
*/
removed: number;
/**
* Number of documents not removed.
*/
ignored: number;
/**
* Documents that have been removed.
*/
old?: DocumentMetadata[] | Document[];
};
/**
* Represents an document collection in a {@link Database}.
*
* See {@link EdgeCollection} for a variant of this interface more suited for
* edge collections.
*
* When using TypeScript, collections can be cast to a specific document data
* type to increase type safety.
*
* @param T - Type to use for document data. Defaults to `any`.
*
* @example
* ```ts
* interface Person {
* name: string;
* }
* const db = new Database();
* const documents = db.collection("persons") as DocumentCollection;
* ```
*/
export interface DocumentCollection = any> extends ArangoCollection {
/**
* Checks whether the collection exists.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const result = await collection.exists();
* // result indicates whether the collection exists
* ```
*/
exists(): Promise;
/**
* Retrieves general information about the collection.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const data = await collection.get();
* // data contains general information about the collection
* ```
*/
get(): Promise;
/**
* Creates a collection with the given `options` and the instance's name.
*
* See also {@link Database.createCollection} and
* {@link Database.createEdgeCollection}.
*
* **Note**: When called on an {@link EdgeCollection} instance in TypeScript,
* the `type` option must still be set to the correct {@link CollectionType}.
* Otherwise this will result in the collection being created with the
* default type (i.e. as a document collection).
*
* @param options - Options for creating the collection.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("potatoes");
* await collection.create();
* // the document collection "potatoes" now exists
* ```
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("friends");
* await collection.create({ type: CollectionType.EDGE_COLLECTION });
* // the edge collection "friends" now exists
* ```
*
* @example
* ```ts
* interface Friend {
* startDate: number;
* endDate?: number;
* }
* const db = new Database();
* const collection = db.collection("friends") as EdgeCollection;
* // even in TypeScript you still need to indicate the collection type
* // if you want to create an edge collection
* await collection.create({ type: CollectionType.EDGE_COLLECTION });
* // the edge collection "friends" now exists
* ```
*/
create(options?: CreateCollectionOptions & {
type?: CollectionType;
}): Promise;
/**
* Retrieves the collection's properties.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const data = await collection.properties();
* // data contains the collection's properties
* ```
*/
properties(): Promise;
/**
* Replaces the properties of the collection.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const result = await collection.setProperties({ waitForSync: true });
* // the collection will now wait for data being written to disk
* // whenever a document is changed
* ```
*/
properties(properties: CollectionPropertiesOptions): Promise;
/**
* Retrieves information about the number of documents in a collection.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const data = await collection.count();
* // data contains the collection's count
* ```
*/
count(): Promise;
/**
* (RocksDB only.) Instructs ArangoDB to recalculate the collection's
* document count to fix any inconsistencies.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("inconsistent-collection");
* const badData = await collection.count();
* // oh no, the collection count looks wrong -- fix it!
* await collection.recalculateCount();
* const goodData = await collection.count();
* // goodData contains the collection's improved count
* ```
*/
recalculateCount(): Promise;
/**
* Retrieves statistics for a collection.
*
* @param details - When true, gets extra engine figures (slow).
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const data = await collection.figures();
* // data contains the collection's figures
* ```
*/
figures(details: boolean): Promise;
}>;
/**
* Retrieves the collection revision ID.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const data = await collection.revision();
* // data contains the collection's revision
* ```
*/
revision(): Promise;
/**
* Retrieves the collection checksum.
*
* @param options - Options for retrieving the checksum.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const data = await collection.checksum();
* // data contains the collection's checksum
* ```
*/
checksum(options?: CollectionChecksumOptions): Promise;
/**
* Instructs ArangoDB to load the collection into memory.
*
* @param count - Whether the number of documents in the collection should
* be included in the server response. Disabling this may speed up this
* process in future versions of ArangoDB.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.load();
* // the collection has now been loaded into memory
* ```
*/
load(count?: true): Promise;
/**
* Instructs ArangoDB to load the collection into memory.
*
* @param count - Whether the number of documents in the collection should
* be included in the server response. Disabling this may speed up this
* process in future versions of ArangoDB.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.load(false);
* // the collection has now been loaded into memory
* ```
*/
load(count: false): Promise;
/**
* (RocksDB only.) Instructs ArangoDB to load as many indexes of the
* collection into memory as permitted by the memory limit.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("indexed-collection");
* await collection.loadIndexes();
* // the indexes are now loaded into memory
* ```
*/
loadIndexes(): Promise;
/**
* Instructs ArangoDB to remove the collection from memory.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.unload();
* // the collection has now been unloaded from memory
* ```
*/
unload(): Promise;
/**
* Renames the collection and updates the instance's `name` to `newName`.
*
* Additionally removes the instance from the {@link Database}'s internal
* cache.
*
* **Note**: Renaming collections may not be supported when ArangoDB is
* running in a cluster configuration.
*
* @param newName - The new name of the collection.
*
* @example
* ```js
* const db = new Database();
* const collection1 = db.collection("some-collection");
* await collection1.rename("other-collection");
* const collection2 = db.collection("some-collection");
* const collection3 = db.collection("other-collection");
* // Note all three collection instances are different objects but
* // collection1 and collection3 represent the same ArangoDB collection!
* ```
*/
rename(newName: string): Promise;
/**
* (MMFiles single-server only.) Rotates the journal of the collection.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const rotated = await collection.rotate();
* ```
*/
rotate(): Promise;
/**
* Deletes all documents in the collection.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.truncate();
* // millions of documents cry out in terror and are suddenly silenced,
* // the collection "some-collection" is now empty
* ```
*/
truncate(): Promise;
/**
* Deletes the collection from the database.
*
* @param options - Options for dropping the collection.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.drop();
* // The collection "some-collection" is now an ex-collection
* ```
*/
drop(options?: CollectionDropOptions): Promise;
/**
* Retrieves the `shardId` of the shard responsible for the given document.
*
* @param document - Document in the collection to look up the `shardId` of.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const responsibleShard = await collection.getResponsibleShard();
* ```
*/
getResponsibleShard(document: Partial>): Promise;
/**
* Derives a document `_id` from the given selector for this collection.
*
* Throws an exception when passed a document or `_id` from a different
* collection.
*
* @param selector - Document `_key`, `_id` or object with either of those
* properties (e.g. a document from this collection).
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const meta = await collection.save({ foo: "bar" }, { returnNew: true });
* const doc = meta.new;
* console.log(collection.documentId(meta)); // via meta._id
* console.log(collection.documentId(doc)); // via doc._id
* console.log(collection.documentId(meta._key)); // also works
* ```
*
* @example
* ```js
* const db = new Database();
* const collection1 = db.collection("some-collection");
* const collection2 = db.collection("other-collection");
* const meta = await collection1.save({ foo: "bar" });
* // Mixing collections is usually a mistake
* console.log(collection1.documentId(meta)); // ok: same collection
* console.log(collection2.documentId(meta)); // throws: wrong collection
* console.log(collection2.documentId(meta._id)); // also throws
* console.log(collection2.documentId(meta._key)); // ok but wrong collection
* ```
*/
documentId(selector: DocumentSelector): string;
/**
* Checks whether a document matching the given key or id exists in this
* collection.
*
* Throws an exception when passed a document or `_id` from a different
* collection.
*
* @param selector - Document `_key`, `_id` or object with either of those
* properties (e.g. a document from this collection).
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const exists = await collection.documentExists("abc123");
* if (!exists) {
* console.log("Document does not exist");
* }
* ```
*/
documentExists(selector: DocumentSelector): Promise;
/**
* Retrieves the document matching the given key or id.
*
* Throws an exception when passed a document or `_id` from a different
* collection.
*
* @param selector - Document `_key`, `_id` or object with either of those
* properties (e.g. a document from this collection).
* @param options - Options for retrieving the document.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* try {
* const document = await collection.document("abc123");
* console.log(document);
* } catch (e) {
* console.error("Could not find document");
* }
* ```
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const document = await collection.document("abc123", { graceful: true });
* if (document) {
* console.log(document);
* } else {
* console.error("Could not find document");
* }
* ```
*/
document(selector: DocumentSelector, options?: CollectionReadOptions): Promise>;
/**
* Retrieves the document matching the given key or id.
*
* Throws an exception when passed a document or `_id` from a different
* collection.
*
* @param selector - Document `_key`, `_id` or object with either of those
* properties (e.g. a document from this collection).
* @param graceful - If set to `true`, `null` is returned instead of an
* exception being thrown if the document does not exist.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* try {
* const document = await collection.document("abc123", false);
* console.log(document);
* } catch (e) {
* console.error("Could not find document");
* }
* ```
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const document = await collection.document("abc123", true);
* if (document) {
* console.log(document);
* } else {
* console.error("Could not find document");
* }
* ```
*/
document(selector: DocumentSelector, graceful: boolean): Promise>;
/**
* Retrieves the documents matching the given key or id values.
*
* Throws an exception when passed a document or `_id` from a different
* collection, or if the document does not exist.
*
* @param selectors - Array of document `_key`, `_id` or objects with either
* of those properties (e.g. a document from this collection).
* @param options - Options for retrieving the documents.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* try {
* const documents = await collection.documents(["abc123", "xyz456"]);
* console.log(documents);
* } catch (e) {
* console.error("Could not find document");
* }
* ```
*/
documents(selectors: (string | ObjectWithKey)[], options?: CollectionBatchReadOptions): Promise[]>;
/**
* Inserts a new document with the given `data` into the collection.
*
* @param data - The contents of the new document.
* @param options - Options for inserting the document.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const result = await collection.save(
* { _key: "a", color: "blue", count: 1 },
* { returnNew: true }
* );
* console.log(result.new.color, result.new.count); // "blue" 1
* ```
*/
save(data: DocumentData, options?: CollectionInsertOptions): Promise;
}>;
/**
* Inserts new documents with the given `data` into the collection.
*
* @param data - The contents of the new documents.
* @param options - Options for inserting the documents.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const result = await collection.saveAll(
* [
* { _key: "a", color: "blue", count: 1 },
* { _key: "b", color: "red", count: 2 },
* ],
* { returnNew: true }
* );
* console.log(result[0].new.color, result[0].new.count); // "blue" 1
* console.log(result[1].new.color, result[1].new.count); // "red" 2
* ```
*/
saveAll(data: Array>, options?: CollectionInsertOptions): Promise;
}>>;
/**
* Replaces an existing document in the collection.
*
* Throws an exception when passed a document or `_id` from a different
* collection.
*
* @param selector - Document `_key`, `_id` or object with either of those
* properties (e.g. a document from this collection).
* @param newData - The contents of the new document.
* @param options - Options for replacing the document.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.save({ _key: "a", color: "blue", count: 1 });
* const result = await collection.replace(
* "a",
* { color: "red" },
* { returnNew: true }
* );
* console.log(result.new.color, result.new.count); // "red" undefined
* ```
*/
replace(selector: DocumentSelector, newData: DocumentData, options?: CollectionReplaceOptions): Promise;
old?: Document;
}>;
/**
* Replaces existing documents in the collection, identified by the `_key` or
* `_id` of each document.
*
* @param newData - The documents to replace.
* @param options - Options for replacing the documents.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.save({ _key: "a", color: "blue", count: 1 });
* await collection.save({ _key: "b", color: "green", count: 3 });
* const result = await collection.replaceAll(
* [
* { _key: "a", color: "red" },
* { _key: "b", color: "yellow", count: 2 }
* ],
* { returnNew: true }
* );
* console.log(result[0].new.color, result[0].new.count); // "red" undefined
* console.log(result[1].new.color, result[1].new.count); // "yellow" 2
* ```
*/
replaceAll(newData: Array & ({
_key: string;
} | {
_id: string;
})>, options?: CollectionReplaceOptions): Promise;
old?: Document;
}>>;
/**
* Updates an existing document in the collection.
*
* Throws an exception when passed a document or `_id` from a different
* collection.
*
* @param selector - Document `_key`, `_id` or object with either of those
* properties (e.g. a document from this collection).
* @param newData - The data for updating the document.
* @param options - Options for updating the document.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.save({ _key: "a", color: "blue", count: 1 });
* const result = await collection.update(
* "a",
* { count: 2 },
* { returnNew: true }
* );
* console.log(result.new.color, result.new.count); // "blue" 2
* ```
*/
update(selector: DocumentSelector, newData: Patch>, options?: CollectionUpdateOptions): Promise;
old?: Document;
}>;
/**
* Updates existing documents in the collection, identified by the `_key` or
* `_id` of each document.
*
* @param newData - The data for updating the documents.
* @param options - Options for updating the documents.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.save({ _key: "a", color: "blue", count: 1 });
* await collection.save({ _key: "b", color: "green", count: 3 });
* const result = await collection.updateAll(
* [
* { _key: "a", count: 2 },
* { _key: "b", count: 4 }
* ],
* { returnNew: true }
* );
* console.log(result[0].new.color, result[0].new.count); // "blue" 2
* console.log(result[1].new.color, result[1].new.count); // "green" 4
* ```
*/
updateAll(newData: Array> & ({
_key: string;
} | {
_id: string;
})>, options?: CollectionUpdateOptions): Promise;
old?: Document;
}>>;
/**
* Removes an existing document from the collection.
*
* Throws an exception when passed a document or `_id` from a different
* collection.
*
* @param selector - Document `_key`, `_id` or object with either of those
* properties (e.g. a document from this collection).
* @param options - Options for removing the document.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.remove("abc123");
* // document with key "abc123" deleted
* ```
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const doc = await collection.document("abc123");
* await collection.remove(doc);
* // document with key "abc123" deleted
* ```
*/
remove(selector: DocumentSelector, options?: CollectionRemoveOptions): Promise;
}>;
/**
* Removes existing documents from the collection.
*
* Throws an exception when passed any document or `_id` from a different
* collection.
*
* @param selectors - Documents `_key`, `_id` or objects with either of those
* properties (e.g. documents from this collection).
* @param options - Options for removing the documents.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.removeAll(["abc123", "def456"]);
* // document with keys "abc123" and "def456" deleted
* ```
*/
removeAll(selectors: DocumentSelector[], options?: CollectionRemoveOptions): Promise;
}>>;
/**
* Bulk imports the given `data` into the collection.
*
* @param data - The data to import, as an array of document data.
* @param options - Options for importing the data.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.import(
* [
* { _key: "jcd", password: "bionicman" },
* { _key: "jreyes", password: "amigo" },
* { _key: "ghermann", password: "zeitgeist" }
* ]
* );
* ```
*/
import(data: DocumentData[], options?: CollectionImportOptions): Promise;
/**
* Bulk imports the given `data` into the collection.
*
* @param data - The data to import, as an array containing a single array of
* attribute names followed by one or more arrays of attribute values for
* each document.
* @param options - Options for importing the data.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.import(
* [
* [ "_key", "password" ],
* [ "jcd", "bionicman" ],
* [ "jreyes", "amigo" ],
* [ "ghermann", "zeitgeist" ]
* ]
* );
* ```
*/
import(data: any[][], options?: CollectionImportOptions): Promise;
/**
* Bulk imports the given `data` into the collection.
*
* If `type` is omitted, `data` must contain one JSON array per line with
* the first array providing the attribute names and all other arrays
* providing attribute values for each document.
*
* If `type` is set to `"documents"`, `data` must contain one JSON document
* per line.
*
* If `type` is set to `"list"`, `data` must contain a JSON array of
* documents.
*
* If `type` is set to `"auto"`, `data` can be in either of the formats
* supported by `"documents"` or `"list"`.
*
* @param data - The data to import as a Buffer (Node), Blob (browser) or
* string.
* @param options - Options for importing the data.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.import(
* '{"_key":"jcd","password":"bionicman"}\r\n' +
* '{"_key":"jreyes","password":"amigo"}\r\n' +
* '{"_key":"ghermann","password":"zeitgeist"}\r\n',
* { type: "documents" } // or "auto"
* );
* ```
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.import(
* '[{"_key":"jcd","password":"bionicman"},' +
* '{"_key":"jreyes","password":"amigo"},' +
* '{"_key":"ghermann","password":"zeitgeist"}]',
* { type: "list" } // or "auto"
* );
* ```
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.import(
* '["_key","password"]\r\n' +
* '["jcd","bionicman"]\r\n' +
* '["jreyes","amigo"]\r\n' +
* '["ghermann","zeitgeist"]\r\n'
* );
* ```
*/
import(data: Buffer | Blob | string, options?: CollectionImportOptions & {
type?: "documents" | "list" | "auto";
}): Promise;
/**
* Retrieves a list of references for all documents in the collection.
*
* @param type - The type of document reference to retrieve.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // const ids = await collection.list("id");
* const ids = await db.query(aql`
* FOR doc IN ${collection}
* RETURN doc._id
* `);
* ```
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // const keys = await collection.list("key");
* const keys = await db.query(aql`
* FOR doc IN ${collection}
* RETURN doc._key
* `);
* ```
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // const paths = await collection.list("path");
* const paths = await db.query(aql`
* FOR doc IN ${collection}
* RETURN CONCAT("/_db/", CURRENT_DATABASE(), "/_api/document/", doc._id)
* `);
* ```
*/
list(type?: SimpleQueryListType): Promise>;
/**
* Retrieves all documents in the collection.
*
* @param options - Options for retrieving the documents.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // const cursor = await collection.all();
* const cursor = await db.query(aql`
* FOR doc IN ${collection}
* RETURN doc
* `);
* ```
*/
all(options?: SimpleQueryAllOptions): Promise>>;
/**
* Retrieves a random document from the collection.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // const doc = await collection.any();
* const cursor = await db.query(aql`
* FOR doc IN ${collection}
* SORT RAND()
* LIMIT 1
* RETURN doc
* `);
* const doc = await cursor.next();
* ```
*/
any(): Promise>;
/**
* Retrieves all documents in the collection matching the given example.
*
* @param example - An object representing an example for documents.
* @param options - Options for retrieving the documents.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // const cursor = await collection.byExample({ flavor: "strawberry" });
* const cursor = await db.query(aql`
* FOR doc IN ${collection}
* FILTER doc.flavor == "strawberry"
* RETURN doc
* `);
* ```
*/
byExample(example: Partial>, options?: SimpleQueryByExampleOptions): Promise>>;
/**
* Retrieves a single document in the collection matching the given example.
*
* @param example - An object representing an example for the document.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // const doc = await collection.firstExample({ flavor: "strawberry" });
* const cursor = await db.query(aql`
* FOR doc IN ${collection}
* FILTER doc.flavor == "strawberry"
* LIMIT 1
* RETURN doc
* `);
* const doc = await cursor.next();
* ```
*/
firstExample(example: Partial>): Promise>;
/**
* Removes all documents in the collection matching the given example.
*
* @param example - An object representing an example for the document.
* @param options - Options for removing the documents.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // const { deleted } = await collection.removeByExample({
* // flavor: "strawberry"
* // });
* const cursor = await db.query(aql`
* RETURN LENGTH(
* FOR doc IN ${collection}
* FILTER doc.flavor == "strawberry"
* REMOVE doc IN ${collection}
* RETURN 1
* )
* `);
* const deleted = await cursor.next();
* ```
*/
removeByExample(example: Partial>, options?: SimpleQueryRemoveByExampleOptions): Promise;
/**
* Replaces all documents in the collection matching the given example.
*
* @param example - An object representing an example for the documents.
* @param newValue - Document data to replace the matching documents with.
* @param options - Options for replacing the documents.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const newValue = { flavor: "chocolate" };
* // const { replaced } = await collection.replaceByExample(
* // { flavor: "strawberry" },
* // newValue
* // );
* const cursor = await db.query(aql`
* RETURN LENGTH(
* FOR doc IN ${collection}
* FILTER doc.flavor == "strawberry"
* REPLACE doc WITH ${newValue} IN ${collection}
* RETURN 1
* )
* `);
* const replaced = await cursor.next();
* ```
*/
replaceByExample(example: Partial>, newValue: DocumentData, options?: SimpleQueryReplaceByExampleOptions): Promise;
/**
* Updates all documents in the collection matching the given example.
*
* @param example - An object representing an example for the documents.
* @param newValue - Document data to update the matching documents with.
* @param options - Options for updating the documents.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const newData = { color: "red" };
* // const { updated } = await collection.updateByExample(
* // { flavor: "strawberry" },
* // newValue
* // );
* const cursor = await db.query(aql`
* RETURN LENGTH(
* FOR doc IN ${collection}
* FILTER doc.flavor == "strawberry"
* UPDATE doc WITH ${newValue} IN ${collection}
* RETURN 1
* )
* `);
* const updated = await cursor.next();
* ```
*/
updateByExample(example: Partial>, newValue: Patch>, options?: SimpleQueryUpdateByExampleOptions): Promise;
/**
* Retrieves all documents matching the given document keys.
*
* @param keys - An array of document keys to look up.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const keys = ["a", "b", "c"];
* // const docs = await collection.byKeys(keys);
* const cursor = await db.query(aql`
* FOR key IN ${keys}
* LET doc = DOCUMENT(${collection}, key)
* RETURN doc
* `);
* const docs = await cursor.all();
* ```
*/
lookupByKeys(keys: string[]): Promise[]>;
/**
* Removes all documents matching the given document keys.
*
* @param keys - An array of document keys to remove.
* @param options - Options for removing the documents.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const keys = ["a", "b", "c"];
* // const { removed, ignored } = await collection.removeByKeys(keys);
* const cursor = await db.query(aql`
* FOR key IN ${keys}
* LET doc = DOCUMENT(${collection}, key)
* FILTER doc
* REMOVE doc IN ${collection}
* RETURN key
* `);
* const removed = await cursor.all();
* const ignored = keys.filter((key) => !removed.includes(key));
* ```
*/
removeByKeys(keys: string[], options?: SimpleQueryRemoveByKeysOptions): Promise>;
/**
* Performs a fulltext query in the given `attribute` on the collection.
*
* @param attribute - Name of the field to search.
* @param query - Fulltext query string to search for.
* @param options - Options for performing the fulltext query.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // const cursor = await collection.fulltext("article", "needle");
* const cursor = await db.query(aql`
* FOR doc IN FULLTEXT(${collection}, "article", "needle")
* RETURN doc
* `);
* ```
*/
fulltext(attribute: string, query: string, options?: SimpleQueryFulltextOptions): Promise>>;
/**
* Returns a list of all index descriptions for the collection.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const indexes = await collection.indexes();
* ```
*/
indexes(): Promise;
/**
* Returns an index description by name or `id` if it exists.
*
* @param selector - Index name, id or object with either property.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const index = await collection.index("some-index");
* ```
*/
index(selector: IndexSelector): Promise;
/**
* Creates a persistent index on the collection if it does not already exist.
*
* @param details - Options for creating the persistent index.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // Create a unique index for looking up documents by username
* await collection.ensureIndex({
* type: "persistent",
* fields: ["username"],
* name: "unique-usernames",
* unique: true
* });
* ```
*/
ensureIndex(details: EnsurePersistentIndexOptions): Promise;
/**
* Creates a hash index on the collection if it does not already exist.
*
* When using the RocksDB storage engine, hash indexes behave identically
* to persistent indexes.
*
* @param details - Options for creating the hash index.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // Create a unique index for looking up documents by username
* await collection.ensureIndex({
* type: "hash",
* fields: ["username"],
* name: "unique-usernames",
* unique: true
* });
* ```
*/
ensureIndex(details: EnsureHashIndexOptions): Promise;
/**
* Creates a skiplist index on the collection if it does not already exist.
*
* When using the RocksDB storage engine, skiplist indexes behave identically
* to persistent indexes.
*
* @param details - Options for creating the skiplist index.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // Create an index for sorting email addresses
* await collection.ensureIndex({
* type: "skiplist",
* fields: ["email"]
* });
* ```
*/
ensureIndex(details: EnsureSkiplistIndexOptions): Promise;
/**
* Creates a TTL index on the collection if it does not already exist.
*
* @param details - Options for creating the TTL index.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // Expire documents with "createdAt" timestamp one day after creation
* await collection.ensureIndex({
* type: "ttl",
* fields: ["createdAt"],
* expireAfter: 60 * 60 * 24 // 24 hours
* });
* ```
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // Expire documents with "expiresAt" timestamp according to their value
* await collection.ensureIndex({
* type: "ttl",
* fields: ["expiresAt"],
* expireAfter: 0 // when attribute value is exceeded
* });
* ```
*/
ensureIndex(details: EnsureTtlIndexOptions): Promise;
/**
* Creates a fulltext index on the collection if it does not already exist.
*
* @param details - Options for creating the fulltext index.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // Create a fulltext index for tokens longer than or equal to 3 characters
* await collection.ensureIndex({
* type: "fulltext",
* fields: ["description"],
* minLength: 3
* });
* ```
*/
ensureIndex(details: EnsureFulltextIndexOptions): Promise;
/**
* Creates a geo index on the collection if it does not already exist.
*
* @param details - Options for creating the geo index.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // Create an index for GeoJSON data
* await collection.ensureIndex({
* type: "geo",
* fields: ["lngLat"],
* geoJson: true
* });
* ```
*/
ensureIndex(details: EnsureGeoIndexOptions): Promise;
/**
* Deletes the index with the given name or `id` from the database.
*
* @param selector - Index name, id or object with either property.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.dropIndex("some-index");
* // The index "some-index" no longer exists
* ```
*/
dropIndex(selector: IndexSelector): Promise;
}
/**
* Represents an edge collection in a {@link Database}.
*
* See {@link DocumentCollection} for a more generic variant of this interface
* more suited for regular document collections.
*
* See also {@link GraphEdgeCollection} for the type representing an edge
* collection in a {@link Graph}.
*
* When using TypeScript, collections can be cast to a specific edge document
* data type to increase type safety.
*
* @param T - Type to use for edge document data. Defaults to `any`.
*
* @example
* ```ts
* interface Friend {
* startDate: number;
* endDate?: number;
* }
* const db = new Database();
* const edges = db.collection("friends") as EdgeCollection;
* ```
*/
export interface EdgeCollection = any> extends DocumentCollection {
/**
* Retrieves the document matching the given key or id.
*
* Throws an exception when passed a document or `_id` from a different
* collection, or if the document does not exist.
*
* @param selector - Document `_key`, `_id` or object with either of those
* properties (e.g. a document from this collection).
* @param options - Options for retrieving the document.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* try {
* const document = await collection.document("abc123");
* console.log(document);
* } catch (e) {
* console.error("Could not find document");
* }
* ```
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const document = await collection.document("abc123", { graceful: true });
* if (document) {
* console.log(document);
* } else {
* console.error("Document does not exist");
* }
* ```
*/
document(selector: DocumentSelector, options?: CollectionReadOptions): Promise>;
/**
* Retrieves the document matching the given key or id.
*
* Throws an exception when passed a document or `_id` from a different
* collection, or if the document does not exist.
*
* @param selector - Document `_key`, `_id` or object with either of those
* properties (e.g. a document from this collection).
* @param graceful - If set to `true`, `null` is returned instead of an
* exception being thrown if the document does not exist.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* try {
* const document = await collection.document("abc123", false);
* console.log(document);
* } catch (e) {
* console.error("Could not find document");
* }
* ```
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const document = await collection.document("abc123", true);
* if (document) {
* console.log(document);
* } else {
* console.error("Document does not exist");
* }
* ```
*/
document(selector: DocumentSelector, graceful: boolean): Promise>;
/**
* Retrieves the documents matching the given key or id values.
*
* Throws an exception when passed a document or `_id` from a different
* collection, or if the document does not exist.
*
* @param selectors - Array of document `_key`, `_id` or objects with either
* of those properties (e.g. a document from this collection).
* @param options - Options for retrieving the documents.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* try {
* const documents = await collection.documents(["abc123", "xyz456"]);
* console.log(documents);
* } catch (e) {
* console.error("Could not find document");
* }
* ```
*/
documents(selectors: (string | ObjectWithKey)[], options?: CollectionBatchReadOptions): Promise[]>;
/**
* Inserts a new document with the given `data` into the collection.
*
* @param data - The contents of the new document.
* @param options - Options for inserting the document.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("friends");
* const result = await collection.save(
* { _from: "users/rana", _to: "users/mudasir", active: false },
* { returnNew: true }
* );
* ```
*/
save(data: EdgeData, options?: CollectionInsertOptions): Promise;
}>;
/**
* Inserts new documents with the given `data` into the collection.
*
* @param data - The contents of the new documents.
* @param options - Options for inserting the documents.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("friends");
* const result = await collection.saveAll(
* [
* { _from: "users/rana", _to: "users/mudasir", active: false },
* { _from: "users/rana", _to: "users/salman", active: true }
* ],
* { returnNew: true }
* );
* ```
*/
saveAll(data: Array>, options?: CollectionInsertOptions): Promise;
}>>;
/**
* Replaces an existing document in the collection.
*
* Throws an exception when passed a document or `_id` from a different
* collection.
*
* @param selector - Document `_key`, `_id` or object with either of those
* properties (e.g. a document from this collection).
* @param newData - The contents of the new document.
* @param options - Options for replacing the document.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("friends");
* await collection.save(
* {
* _key: "musadir",
* _from: "users/rana",
* _to: "users/mudasir",
* active: true,
* best: true
* }
* );
* const result = await collection.replace(
* "musadir",
* { active: false },
* { returnNew: true }
* );
* console.log(result.new.active, result.new.best); // false undefined
* ```
*/
replace(selector: DocumentSelector, newData: DocumentData, options?: CollectionReplaceOptions): Promise;
old?: Edge;
}>;
/**
* Replaces existing documents in the collection, identified by the `_key` or
* `_id` of each document.
*
* @param newData - The documents to replace.
* @param options - Options for replacing the documents.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("friends");
* await collection.save(
* {
* _key: "musadir",
* _from: "users/rana",
* _to: "users/mudasir",
* active: true,
* best: true
* }
* );
* await collection.save(
* {
* _key: "salman",
* _from: "users/rana",
* _to: "users/salman",
* active: false,
* best: false
* }
* );
* const result = await collection.replaceAll(
* [
* { _key: "musadir", active: false },
* { _key: "salman", active: true, best: true }
* ],
* { returnNew: true }
* );
* console.log(result[0].new.active, result[0].new.best); // false undefined
* console.log(result[1].new.active, result[1].new.best); // true true
* ```
*/
replaceAll(newData: Array & ({
_key: string;
} | {
_id: string;
})>, options?: CollectionReplaceOptions): Promise;
old?: Edge;
}>>;
/**
* Updates an existing document in the collection.
*
* Throws an exception when passed a document or `_id` from a different
* collection.
*
* @param selector - Document `_key`, `_id` or object with either of those
* properties (e.g. a document from this collection).
* @param newData - The data for updating the document.
* @param options - Options for updating the document.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("friends");
* await collection.save(
* {
* _key: "musadir",
* _from: "users/rana",
* _to: "users/mudasir",
* active: true,
* best: true
* }
* );
* const result = await collection.update(
* "musadir",
* { active: false },
* { returnNew: true }
* );
* console.log(result.new.active, result.new.best); // false true
* ```
*/
update(selector: DocumentSelector, newData: Patch>, options?: CollectionUpdateOptions): Promise;
old?: Edge;
}>;
/**
* Updates existing documents in the collection, identified by the `_key` or
* `_id` of each document.
*
* @param newData - The data for updating the documents.
* @param options - Options for updating the documents.
* ```js
* const db = new Database();
* const collection = db.collection("friends");
* await collection.save(
* {
* _key: "musadir",
* _from: "users/rana",
* _to: "users/mudasir",
* active: true,
* best: true
* }
* );
* await collection.save(
* {
* _key: "salman",
* _from: "users/rana",
* _to: "users/salman",
* active: false,
* best: false
* }
* );
* const result = await collection.updateAll(
* [
* { _key: "musadir", active: false },
* { _key: "salman", active: true, best: true }
* ],
* { returnNew: true }
* );
* console.log(result[0].new.active, result[0].new.best); // false true
* console.log(result[1].new.active, result[1].new.best); // true true
* ```
*/
updateAll(newData: Array> & ({
_key: string;
} | {
_id: string;
})>, options?: CollectionUpdateOptions): Promise;
old?: Edge;
}>>;
/**
* Removes an existing document from the collection.
*
* Throws an exception when passed a document or `_id` from a different
* collection.
*
* @param selector - Document `_key`, `_id` or object with either of those
* properties (e.g. a document from this collection).
* @param options - Options for removing the document.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("friends");
* const doc = await collection.document("musadir");
* await collection.remove(doc);
* // document with key "musadir" deleted
* ```
*/
remove(selector: DocumentSelector, options?: CollectionRemoveOptions): Promise;
}>;
/**
* Removes existing documents from the collection.
*
* Throws an exception when passed any document or `_id` from a different
* collection.
*
* @param selectors - Documents `_key`, `_id` or objects with either of those
* properties (e.g. documents from this collection).
* @param options - Options for removing the documents.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("friends");
* await collection.removeAll(["musadir", "salman"]);
* // document with keys "musadir" and "salman" deleted
* ```
*/
removeAll(selectors: DocumentSelector[], options?: CollectionRemoveOptions): Promise;
}>>;
/**
* Bulk imports the given `data` into the collection.
*
* @param data - The data to import, as an array of edge data.
* @param options - Options for importing the data.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.import(
* [
* { _key: "x", _from: "vertices/a", _to: "vertices/b", weight: 1 },
* { _key: "y", _from: "vertices/a", _to: "vertices/c", weight: 2 }
* ]
* );
* ```
*/
import(data: EdgeData[], options?: CollectionImportOptions): Promise;
/**
* Bulk imports the given `data` into the collection.
*
* @param data - The data to import, as an array containing a single array of
* attribute names followed by one or more arrays of attribute values for
* each edge document.
* @param options - Options for importing the data.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.import(
* [
* [ "_key", "_from", "_to", "weight" ],
* [ "x", "vertices/a", "vertices/b", 1 ],
* [ "y", "vertices/a", "vertices/c", 2 ]
* ]
* );
* ```
*/
import(data: any[][], options?: CollectionImportOptions): Promise;
/**
* Bulk imports the given `data` into the collection.
*
* If `type` is omitted, `data` must contain one JSON array per line with
* the first array providing the attribute names and all other arrays
* providing attribute values for each edge document.
*
* If `type` is set to `"documents"`, `data` must contain one JSON document
* per line.
*
* If `type` is set to `"list"`, `data` must contain a JSON array of
* edge documents.
*
* If `type` is set to `"auto"`, `data` can be in either of the formats
* supported by `"documents"` or `"list"`.
*
* @param data - The data to import as a Buffer (Node), Blob (browser) or
* string.
* @param options - Options for importing the data.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.import(
* '{"_key":"x","_from":"vertices/a","_to":"vertices/b","weight":1}\r\n' +
* '{"_key":"y","_from":"vertices/a","_to":"vertices/c","weight":2}\r\n',
* { type: "documents" } // or "auto"
* );
* ```
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.import(
* '[{"_key":"x","_from":"vertices/a","_to":"vertices/b","weight":1},' +
* '{"_key":"y","_from":"vertices/a","_to":"vertices/c","weight":2}]',
* { type: "list" } // or "auto"
* );
* ```
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* await collection.import(
* '["_key","_from","_to","weight"]\r\n' +
* '["x","vertices/a","vertices/b",1]\r\n' +
* '["y","vertices/a","vertices/c",2]\r\n'
* );
* ```
*/
import(data: Buffer | Blob | string, options?: CollectionImportOptions & {
type?: "documents" | "list" | "auto";
}): Promise;
/**
* Retrieves all documents in the collection.
*
* @param options - Options for retrieving the documents.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // const cursor = await collection.all();
* const cursor = await db.query(aql`
* FOR doc IN ${collection}
* RETURN doc
* `);
* ```
*/
all(options?: SimpleQueryAllOptions): Promise>>;
/**
* Retrieves a random document from the collection.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // const doc = await collection.any();
* const cursor = await db.query(aql`
* FOR doc IN ${collection}
* SORT RAND()
* LIMIT 1
* RETURN doc
* `);
* const doc = await cursor.next();
* ```
*/
any(): Promise>;
/**
* Retrieves all documents in the collection matching the given example.
*
* @param example - An object representing an example for documents.
* @param options - Options for retrieving the documents.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // const cursor = await collection.byExample({ flavor: "strawberry" });
* const cursor = await db.query(aql`
* FOR doc IN ${collection}
* FILTER doc.flavor == "strawberry"
* RETURN doc
* `);
* ```
*/
byExample(example: Partial>, options?: SimpleQueryByExampleOptions): Promise>>;
/**
* Retrieves a single document in the collection matching the given example.
*
* @param example - An object representing an example for the document.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // const doc = await collection.firstExample({ flavor: "strawberry" });
* const cursor = await db.query(aql`
* FOR doc IN ${collection}
* FILTER doc.flavor == "strawberry"
* LIMIT 1
* RETURN doc
* `);
* const doc = await cursor.next();
* ```
*/
firstExample(example: Partial>): Promise>;
/**
* Retrieves all documents matching the given document keys.
*
* @param keys - An array of document keys to look up.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const keys = ["a", "b", "c"];
* // const docs = await collection.byKeys(keys);
* const cursor = await db.query(aql`
* FOR key IN ${keys}
* LET doc = DOCUMENT(${collection}, key)
* RETURN doc
* `);
* const docs = await cursor.all();
* ```
*/
lookupByKeys(keys: string[]): Promise[]>;
/**
* Performs a fulltext query in the given `attribute` on the collection.
*
* @param attribute - Name of the field to search.
* @param query - Fulltext query string to search for.
* @param options - Options for performing the fulltext query.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* // const cursor = await collection.fulltext("article", "needle");
* const cursor = await db.query(aql`
* FOR doc IN FULLTEXT(${collection}, "article", "needle")
* RETURN doc
* `);
* ```
*/
fulltext(attribute: string, query: string, options?: SimpleQueryFulltextOptions): Promise>>;
/**
* Retrieves a list of all edges of the document matching the given
* `selector`.
*
* Throws an exception when passed a document or `_id` from a different
* collection.
*
* @param selector - Document `_key`, `_id` or object with either of those
* properties (e.g. a document from this collection).
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("edges");
* await collection.import([
* ["_key", "_from", "_to"],
* ["x", "vertices/a", "vertices/b"],
* ["y", "vertices/a", "vertices/c"],
* ["z", "vertices/d", "vertices/a"],
* ]);
* const edges = await collection.edges("vertices/a");
* console.log(edges.map((edge) => edge._key)); // ["x", "y", "z"]
* ```
*/
edges(selector: DocumentSelector): Promise>;
/**
* Retrieves a list of all incoming edges of the document matching the given
* `selector`.
*
* Throws an exception when passed a document or `_id` from a different
* collection.
*
* @param selector - Document `_key`, `_id` or object with either of those
* properties (e.g. a document from this collection).
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("edges");
* await collection.import([
* ["_key", "_from", "_to"],
* ["x", "vertices/a", "vertices/b"],
* ["y", "vertices/a", "vertices/c"],
* ["z", "vertices/d", "vertices/a"],
* ]);
* const edges = await collection.inEdges("vertices/a");
* console.log(edges.map((edge) => edge._key)); // ["z"]
* ```
*/
inEdges(selector: DocumentSelector): Promise>;
/**
* Retrieves a list of all outgoing edges of the document matching the given
* `selector`.
*
* Throws an exception when passed a document or `_id` from a different
* collection.
*
* @param selector - Document `_key`, `_id` or object with either of those
* properties (e.g. a document from this collection).
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("edges");
* await collection.import([
* ["_key", "_from", "_to"],
* ["x", "vertices/a", "vertices/b"],
* ["y", "vertices/a", "vertices/c"],
* ["z", "vertices/d", "vertices/a"],
* ]);
* const edges = await collection.outEdges("vertices/a");
* console.log(edges.map((edge) => edge._key)); // ["x", "y"]
* ```
*/
outEdges(selector: DocumentSelector): Promise>;
/**
* Performs a traversal starting from the given `startVertex` and following
* edges contained in this edge collection.
*
* Throws an exception when passed a document or `_id` from a different
* collection.
*
* See also {@link Graph.traversal}.
*
* @param startVertex - Document `_key`, `_id` or object with either of those
* properties (e.g. a document from this collection).
* @param options - Options for performing the traversal.
*
* @deprecated Simple Queries have been deprecated in ArangoDB 3.4 and can be
* replaced with AQL queries.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("edges");
* await collection.import([
* ["_key", "_from", "_to"],
* ["x", "vertices/a", "vertices/b"],
* ["y", "vertices/b", "vertices/c"],
* ["z", "vertices/c", "vertices/d"],
* ]);
* const result = await collection.traversal("vertices/a", {
* direction: "outbound",
* init: "result.vertices = [];",
* visitor: "result.vertices.push(vertex._key);",
* });
* console.log(result.vertices); // ["a", "b", "c", "d"]
* ```
*/
traversal(startVertex: DocumentSelector, options?: TraversalOptions): Promise;
}
/**
* @internal
* @hidden
*/
export declare class Collection = any> implements EdgeCollection, DocumentCollection {
protected _name: string;
protected _db: Database;
/**
* @internal
* @hidden
*/
constructor(db: Database, name: string);
protected _get>(path: string, qs?: any): Promise;
protected _put>(path: string, body?: any): Promise;
get isArangoCollection(): true;
get name(): string;
get(): Promise;
exists(): Promise;
create(options?: CreateCollectionOptions & {
type?: CollectionType;
}): Promise;
properties(properties?: CollectionPropertiesOptions): Promise;
count(): Promise;
recalculateCount(): Promise;
figures(details?: boolean): Promise;
}>;
revision(): Promise;
checksum(options?: CollectionChecksumOptions): Promise;
load(count?: boolean): Promise;
loadIndexes(): Promise;
unload(): Promise;
rename(newName: string): Promise;
rotate(): Promise;
truncate(): Promise;
drop(options?: CollectionDropOptions): Promise;
getResponsibleShard(document: Partial>): Promise;
documentId(selector: DocumentSelector): string;
documentExists(selector: DocumentSelector): Promise;
documents(selectors: (string | ObjectWithKey)[], options?: CollectionBatchReadOptions): Promise;
document(selector: DocumentSelector, options?: boolean | CollectionReadOptions): Promise;
save(data: DocumentData, options?: CollectionInsertOptions): Promise;
saveAll(data: Array>, options?: CollectionInsertOptions): Promise;
replace(selector: DocumentSelector, newData: DocumentData, options?: CollectionReplaceOptions): Promise;
replaceAll(newData: Array & ({
_key: string;
} | {
_id: string;
})>, options?: CollectionReplaceOptions): Promise;
update(selector: DocumentSelector, newData: Patch>, options?: CollectionUpdateOptions): Promise;
updateAll(newData: Array> & ({
_key: string;
} | {
_id: string;
})>, options?: CollectionUpdateOptions): Promise;
remove(selector: DocumentSelector, options?: CollectionRemoveOptions): Promise;
removeAll(selectors: DocumentSelector[], options?: CollectionRemoveOptions): Promise;
import(data: Buffer | Blob | string | any[], options?: CollectionImportOptions & {
type?: "documents" | "list" | "auto";
}): Promise;
protected _edges(selector: DocumentSelector, direction?: "in" | "out"): Promise;
edges(vertex: DocumentSelector): Promise;
inEdges(vertex: DocumentSelector): Promise;
outEdges(vertex: DocumentSelector): Promise;
traversal(startVertex: DocumentSelector, options?: TraversalOptions): Promise;
list(type?: SimpleQueryListType): Promise>;
all(options?: SimpleQueryAllOptions): Promise>;
any(): Promise;
byExample(example: Partial>, options?: SimpleQueryByExampleOptions): Promise>;
firstExample(example: Partial>): Promise;
removeByExample(example: Partial>, options?: SimpleQueryRemoveByExampleOptions): Promise;
replaceByExample(example: Partial>, newValue: DocumentData, options?: SimpleQueryReplaceByExampleOptions): Promise;
updateByExample(example: Partial>, newValue: Patch>, options?: SimpleQueryUpdateByExampleOptions): Promise;
lookupByKeys(keys: string[]): Promise;
removeByKeys(keys: string[], options?: SimpleQueryRemoveByKeysOptions): Promise;
indexes(): Promise;
index(selector: IndexSelector): Promise;
ensureIndex(options: EnsureHashIndexOptions | EnsureSkiplistIndexOptions | EnsurePersistentIndexOptions | EnsureGeoIndexOptions | EnsureFulltextIndexOptions | EnsureTtlIndexOptions): Promise;
dropIndex(selector: IndexSelector): Promise;
fulltext(attribute: string, query: string, { index, ...options }?: SimpleQueryFulltextOptions): Promise>;
}
//# sourceMappingURL=collection.d.ts.map