Class Collection

Exposes the operations which are available to be performed against a collection. Namely the ability to perform KV operations.

Accessors

  • get name(): string
  • The name of the collection this Collection object references.

    Returns string

Methods

  • Returns a BinaryCollection object reference, allowing access to various binary operations possible against a collection.

    Returns BinaryCollection

  • Checks whether a specific document exists or not.

    Parameters

    • key: string

      The document key to check for existence.

    • Optional options: ExistsOptions

      Optional parameters for this operation.

    • Optional callback: NodeCallback<ExistsResult>

      A node-style callback to be invoked after execution.

    Returns Promise<ExistsResult>

  • Retrieves the value of a document from the collection.

    Parameters

    • key: string

      The document key to retrieve.

    • Optional options: GetOptions

      Optional parameters for this operation.

    • Optional callback: NodeCallback<GetResult>

      A node-style callback to be invoked after execution.

    Returns Promise<GetResult>

  • Retrieves the value of the document from all available replicas. Note that as replication is asynchronous, each node may return a different value.

    Parameters

    Returns Promise<GetReplicaResult[]>

  • Locks a document and retrieves the value of that document at the time it is locked.

    Parameters

    • key: string

      The document key to retrieve and lock.

    • lockTime: number

      The amount of time to lock the document for, specified in seconds.

    • Optional options: GetAndLockOptions

      Optional parameters for this operation.

    • Optional callback: NodeCallback<GetResult>

      A node-style callback to be invoked after execution.

    Returns Promise<GetResult>

  • Retrieves the value of the document and simultanously updates the expiry time for the same document.

    Parameters

    • key: string

      The document to fetch and touch.

    • expiry: number

      The new expiry to apply to the document, specified in seconds.

    • Optional options: GetAndTouchOptions

      Optional parameters for this operation.

    • Optional callback: NodeCallback<GetResult>

      A node-style callback to be invoked after execution.

    Returns Promise<GetResult>

  • Retrieves the value of the document from any of the available replicas. This will return as soon as the first response is received from any replica node.

    Parameters

    Returns Promise<GetReplicaResult>

  • Inserts a new document to the collection, failing if the document already exists.

    Parameters

    • key: string

      The document key to insert.

    • value: any

      The value of the document to insert.

    • Optional options: InsertOptions

      Optional parameters for this operation.

    • Optional callback: NodeCallback<MutationResult>

      A node-style callback to be invoked after execution.

    Returns Promise<MutationResult>

  • Returns a CouchbaseList permitting simple list storage in a document.

    Parameters

    • key: string

      The document key the data-structure resides in.

    Returns CouchbaseList

  • Performs a lookup-in operation against a document, fetching individual fields or information about specific fields inside the document value.

    Parameters

    • key: string

      The document key to look in.

    • specs: LookupInSpec[]

      A list of specs describing the data to fetch from the document.

    • Optional options: LookupInOptions

      Optional parameters for this operation.

    • Optional callback: NodeCallback<LookupInResult>

      A node-style callback to be invoked after execution.

    Returns Promise<LookupInResult>

  • Performs a lookup-in operation against a document, fetching individual fields or information about specific fields inside the document value from all available replicas. Note that as replication is asynchronous, each node may return a different value.

    Parameters

    • key: string

      The document key to look in.

    • specs: LookupInSpec[]

      A list of specs describing the data to fetch from the document.

    • Optional options: LookupInOptions

      Optional parameters for this operation.

    • Optional callback: NodeCallback<LookupInReplicaResult[]>

      A node-style callback to be invoked after execution.

    Returns Promise<LookupInReplicaResult[]>

  • Performs a lookup-in operation against a document, fetching individual fields or information about specific fields inside the document value from any of the available replicas in the cluster.

    Parameters

    • key: string

      The document key to look in.

    • specs: LookupInSpec[]

      A list of specs describing the data to fetch from the document.

    • Optional options: LookupInOptions

      Optional parameters for this operation.

    • Optional callback: NodeCallback<LookupInReplicaResult>

      A node-style callback to be invoked after execution.

    Returns Promise<LookupInReplicaResult>

  • Returns a CouchbaseMap permitting simple map storage in a document.

    Parameters

    • key: string

      The document key the data-structure resides in.

    Returns CouchbaseMap

  • Performs a mutate-in operation against a document. Allowing atomic modification of specific fields within a document. Also enables access to document extended-attributes.

    Parameters

    • key: string

      The document key to mutate.

    • specs: MutateInSpec[]

      A list of specs describing the operations to perform on the document.

    • Optional options: MutateInOptions

      Optional parameters for this operation.

    • Optional callback: NodeCallback<MutateInResult>

      A node-style callback to be invoked after execution.

    Returns Promise<MutateInResult>

  • Returns a CouchbaseQueue permitting simple queue storage in a document.

    Parameters

    • key: string

      The document key the data-structure resides in.

    Returns CouchbaseQueue

  • Remove an existing document from the collection.

    Parameters

    • key: string

      The document key to remove.

    • Optional options: RemoveOptions

      Optional parameters for this operation.

    • Optional callback: NodeCallback<MutationResult>

      A node-style callback to be invoked after execution.

    Returns Promise<MutationResult>

  • Replaces the value of an existing document. Failing if the document does not exist.

    Parameters

    • key: string

      The document key to replace.

    • value: any

      The new value for the document.

    • Optional options: ReplaceOptions

      Optional parameters for this operation.

    • Optional callback: NodeCallback<MutationResult>

      A node-style callback to be invoked after execution.

    Returns Promise<MutationResult>

  • Performs a key-value scan operation.

    Use this API for low concurrency batch queries where latency is not a critical as the system may have to scan a lot of documents to find the matching documents. For low latency range queries, it is recommended that you use SQL++ with the necessary indexes.

    Parameters

    Returns Promise<ScanResult[]>

  • Returns a CouchbaseSet permitting simple set storage in a document.

    Parameters

    • key: string

      The document key the data-structure resides in.

    Returns CouchbaseSet

  • Updates the expiry on an existing document.

    Parameters

    • key: string

      The document key to touch.

    • expiry: number

      The new expiry to set for the document, specified in seconds.

    • Optional options: TouchOptions

      Optional parameters for this operation.

    • Optional callback: NodeCallback<MutationResult>

      A node-style callback to be invoked after execution.

    Returns Promise<MutationResult>

  • Unlocks a previously locked document.

    Parameters

    • key: string

      The document key to unlock.

    • cas: CasInput

      The CAS of the document, used to validate lock ownership.

    • Optional options: UnlockOptions

      Optional parameters for this operation.

    • Optional callback: NodeCallback<void>

      A node-style callback to be invoked after execution.

    Returns Promise<void>

  • Upserts a document to the collection. This operation succeeds whether or not the document already exists.

    Parameters

    • key: string

      The document key to upsert.

    • value: any

      The new value for the document.

    • Optional options: UpsertOptions

      Optional parameters for this operation.

    • Optional callback: NodeCallback<MutationResult>

      A node-style callback to be invoked after execution.

    Returns Promise<MutationResult>