Couchbase .NET SDK __CB_SDK_VERSION__

Show / Hide Table of Contents

Interface ICouchbaseCollection

Represents a collection of JSON objects in Couchbase.

Namespace: Couchbase.KeyValue
Assembly: Couchbase.NetClient.dll
Syntax
public interface ICouchbaseCollection

Properties

View Source

Binary

A special collection for non-JSON operations; maps to binary operation in the older API's.

Declaration
IBinaryCollection Binary { get; }
Property Value
Type Description
IBinaryCollection
View Source

Cid

The identifier for the collection.

Declaration
uint? Cid { get; }
Property Value
Type Description
uint?
View Source

IsDefaultCollection

Returns true if this is the default collection in the default scope.

Declaration
bool IsDefaultCollection { get; }
Property Value
Type Description
bool
View Source

Name

The name of the collection.

Declaration
string Name { get; }
Property Value
Type Description
string
View Source

QueryIndexes

Provides access to the indexes at the Collection level.

Declaration
[InterfaceStability(Level.Volatile)]
ICollectionQueryIndexManager QueryIndexes { get; }
Property Value
Type Description
ICollectionQueryIndexManager
View Source

Scope

Scope which owns this collection.

Declaration
IScope Scope { get; }
Property Value
Type Description
IScope
View Source

SubdocAccessDeleted

Returns true if the bucket supports accessDeleted.

Declaration
bool SubdocAccessDeleted { get; }
Property Value
Type Description
bool

Methods

View Source

ExistsAsync(string, ExistsOptions?)

Returns true if a document exists for a given id, otherwise false.

Declaration
Task<IExistsResult> ExistsAsync(string id, ExistsOptions? options = null)
Parameters
Type Name Description
string id

The id of the document.

ExistsOptions options

Any optional parameters.

Returns
Type Description
Task<IExistsResult>

An asynchronous Task containing an IExistsResult object with a boolean value indicating the presence of the document.

View Source

GetAllReplicasAsync(string, GetAllReplicasOptions?)

Gets a list of document data from the server, leveraging both the active and all available replicas.

Declaration
IEnumerable<Task<IGetReplicaResult>> GetAllReplicasAsync(string id, GetAllReplicasOptions? options = null)
Parameters
Type Name Description
string id

The id of the document.

GetAllReplicasOptions options

Any optional parameters.

Returns
Type Description
IEnumerable<Task<IGetReplicaResult>>

An asynchronous Task containing the JSON object or scalar encapsulated in a list of IGetReplicaResult API objects.

View Source

GetAndLockAsync(string, TimeSpan, GetAndLockOptions?)

Gets a document for a given id and places a pessimistic lock on it for mutations.

Declaration
Task<IGetResult> GetAndLockAsync(string id, TimeSpan expiry, GetAndLockOptions? options = null)
Parameters
Type Name Description
string id

The id of the document.

TimeSpan expiry

The duration of the lock.

GetAndLockOptions options

Any optional parameters.

Returns
Type Description
Task<IGetResult>

An asynchronous Task The JSON object or scalar encapsulated in a IGetResult API object.

Remarks

The maximum amount of time a key can be locked is 30 seconds; any parameter you provide that is more than 30 seconds will be set to 30 seconds; negative numbers will be interpreted as 30 seconds also.

View Source

GetAndTouchAsync(string, TimeSpan, GetAndTouchOptions?)

Gets a document for a given id and extends its expiration.

Declaration
Task<IGetResult> GetAndTouchAsync(string id, TimeSpan expiry, GetAndTouchOptions? options = null)
Parameters
Type Name Description
string id

The id of the document.

TimeSpan expiry

The duration of the lock.

GetAndTouchOptions options

Any optional parameters.

Returns
Type Description
Task<IGetResult>

An asynchronous Task The JSON object or scalar encapsulated in a IGetResult API object.

View Source

GetAnyReplicaAsync(string, GetAnyReplicaOptions?)

Gets a document for a given id, leveraging both the active and all available replicas. This method follows the same semantics of GetAllReplicas (including the fetch from ACTIVE), but returns the first response as opposed to returning all responses.

Declaration
Task<IGetReplicaResult> GetAnyReplicaAsync(string id, GetAnyReplicaOptions? options = null)
Parameters
Type Name Description
string id

The id of the document.

GetAnyReplicaOptions options

Any optional parameters.

Returns
Type Description
Task<IGetReplicaResult>

An asynchronous Task The JSON object or scalar encapsulated in a IGetReplicaResult API object.

View Source

GetAsync(string, GetOptions?)

Fetches a value from the server if it exists.

Declaration
Task<IGetResult> GetAsync(string id, GetOptions? options = null)
Parameters
Type Name Description
string id

The id of the document.

GetOptions options

Optional parameters.

Returns
Type Description
Task<IGetResult>

An asynchronous Task containing the JSON object or scalar encapsulated in an IGetResult API object.

View Source

InsertAsync<T>(string, T, InsertOptions?)

Insert a JSON document, failing if it already exists. Maps to Memcached Add command.

Declaration
Task<IMutationResult> InsertAsync<T>(string id, T content, InsertOptions? options = null)
Parameters
Type Name Description
string id

The id of the document.

T content

The content or document body.

InsertOptions options

Any optional parameters.

Returns
Type Description
Task<IMutationResult>

An asynchronous Task containing a IMutationResult object if successful otherwise an exception with details for the reason the operation failed.

Type Parameters
Name Description
T

The Type of content to insert.

View Source

LookupInAllReplicasAsync(string, IEnumerable<LookupInSpec>, LookupInAllReplicasOptions?)

Gets a stream of document data from the server using LookupIn, leveraging both the active and all available replicas.

Declaration
[InterfaceStability(Level.Volatile)]
IAsyncEnumerable<ILookupInReplicaResult> LookupInAllReplicasAsync(string id, IEnumerable<LookupInSpec> specs, LookupInAllReplicasOptions? options = null)
Parameters
Type Name Description
string id

The id of the document.

IEnumerable<LookupInSpec> specs

An array of fetch operations - requires at least one: exists, get, count. There is a server enforced maximum of 16 sub document operations allowed per call.

LookupInAllReplicasOptions options

Any optional parameters.

Returns
Type Description
IAsyncEnumerable<ILookupInReplicaResult>
View Source

LookupInAnyReplicaAsync(string, IEnumerable<LookupInSpec>, LookupInAnyReplicaOptions?)

Gets a stream of document data from the server using LookupIn, leveraging both the active and all available replicas, returning only the first result.

Declaration
[InterfaceStability(Level.Volatile)]
Task<ILookupInReplicaResult> LookupInAnyReplicaAsync(string id, IEnumerable<LookupInSpec> specs, LookupInAnyReplicaOptions? options = null)
Parameters
Type Name Description
string id

The id of the document.

IEnumerable<LookupInSpec> specs

An array of fetch operations - requires at least one: exists, get, count. There is a server enforced maximum of 16 sub document operations allowed per call.

LookupInAnyReplicaOptions options

Any optional parameters.

Returns
Type Description
Task<ILookupInReplicaResult>
View Source

LookupInAsync(string, IEnumerable<LookupInSpec>, LookupInOptions?)

Allows the chaining of Sub-Document fetch operations like, Get("path") and Exists("path") into a single atomic fetch.

Declaration
Task<ILookupInResult> LookupInAsync(string id, IEnumerable<LookupInSpec> specs, LookupInOptions? options = null)
Parameters
Type Name Description
string id

The id of the document.

IEnumerable<LookupInSpec> specs

An array of fetch operations - requires at least one: exists, get, count. There is a server enforced maximum of 16 sub document operations allowed per call.

LookupInOptions options

Any optional parameters.

Returns
Type Description
Task<ILookupInResult>

An asynchronous Task containing the results of the lookup as an ILookupInResult object.

View Source

MutateInAsync(string, IEnumerable<MutateInSpec>, MutateInOptions?)

Allows the chaining of Sub-Document mutation operations on a specific document in a single atomic transaction.

Declaration
Task<IMutateInResult> MutateInAsync(string id, IEnumerable<MutateInSpec> specs, MutateInOptions? options = null)
Parameters
Type Name Description
string id

The id of the document.

IEnumerable<MutateInSpec> specs

An array of fetch operations - requires at least one: exists, get, count. There is a server enforced maximum of 16 sub document operations allowed per call.

MutateInOptions options

Any optional parameters.

Returns
Type Description
Task<IMutateInResult>

An asynchronous Task containing the results of the mutation as an IMutateInResult object.

View Source

RemoveAsync(string, RemoveOptions?)

Removes an existing document in Couchbase server, failing if it does not exist.

Declaration
Task RemoveAsync(string id, RemoveOptions? options = null)
Parameters
Type Name Description
string id

The id of the document.

RemoveOptions options

Any optional parameters.

Returns
Type Description
Task

An asynchronous Task object for awaiting.

View Source

ReplaceAsync<T>(string, T, ReplaceOptions?)

Replaces an existing document in Couchbase server, failing if it does not exist. Maps to Memcached SET command.

Declaration
Task<IMutationResult> ReplaceAsync<T>(string id, T content, ReplaceOptions? options = null)
Parameters
Type Name Description
string id

The id of the document.

T content

The content or document body.

ReplaceOptions options

Any optional parameters.

Returns
Type Description
Task<IMutationResult>

An asynchronous Task containing a IMutationResult object if successful otherwise an exception with details for the reason the operation failed.

Type Parameters
Name Description
T

The Type of content to insert.

View Source

ScanAsync(IScanType, ScanOptions?)

Declaration
IAsyncEnumerable<IScanResult> ScanAsync(IScanType scanType, ScanOptions? options = null)
Parameters
Type Name Description
IScanType scanType
ScanOptions options
Returns
Type Description
IAsyncEnumerable<IScanResult>
View Source

TouchAsync(string, TimeSpan, TouchOptions?)

Updates the expiration a document given an id, without modifying or returning its value.

Declaration
Task TouchAsync(string id, TimeSpan expiry, TouchOptions? options = null)
Parameters
Type Name Description
string id

The id of the document.

TimeSpan expiry

The TimeSpan expiry of the new expiration time.

TouchOptions options

Any optional parameters.

Returns
Type Description
Task

An asynchronous Task object for awaiting.

View Source

TouchWithCasAsync(string, TimeSpan, TouchOptions?)

Updates the expiration a document given an id, without modifying or returning its value.

Declaration
Task<IMutationResult?> TouchWithCasAsync(string id, TimeSpan expiry, TouchOptions? options = null)
Parameters
Type Name Description
string id

The id of the document.

TimeSpan expiry

The TimeSpan expiry of the new expiration time.

TouchOptions options

Any optional parameters.

Returns
Type Description
Task<IMutationResult>

An asynchronous Task object for awaiting, with a IMutationResult containing a Cas value.

View Source

UnlockAsync(string, ulong, UnlockOptions?)

Unlocks a document pessimistically locked by a GetAndLock operation.

Declaration
Task UnlockAsync(string id, ulong cas, UnlockOptions? options = null)
Parameters
Type Name Description
string id

The id of the document.

ulong cas

The CAS from the GetAndLock operation.

UnlockOptions options

Any optional parameters.

Returns
Type Description
Task

An asynchronous Task object for awaiting.

View Source

UnlockAsync<T>(string, ulong, UnlockOptions?)

Declaration
[Obsolete("Use overload that does not have a Type parameter T.")]
Task UnlockAsync<T>(string id, ulong cas, UnlockOptions? options = null)
Parameters
Type Name Description
string id
ulong cas
UnlockOptions options
Returns
Type Description
Task
Type Parameters
Name Description
T
View Source

UpsertAsync<T>(string, T, UpsertOptions?)

Insert a new document or overwrite an existing document in Couchbase server. Maps to Memcached Set command.

Declaration
Task<IMutationResult> UpsertAsync<T>(string id, T content, UpsertOptions? options = null)
Parameters
Type Name Description
string id

The id of the document.

T content

The content or document body.

UpsertOptions options

Any optional parameters.

Returns
Type Description
Task<IMutationResult>

An asynchronous Task containing an IMutationResult object if successful otherwise an exception with details for the reason the operation failed.

Type Parameters
Name Description
T

The Type of content to upsert.

Extension Methods

CollectionExtensions.Dictionary<TValue>(ICouchbaseCollection, string)
CollectionExtensions.ExistsAsync(ICouchbaseCollection, string)
CollectionExtensions.ExistsAsync(ICouchbaseCollection, string, Action<ExistsOptions>)
CollectionExtensions.GetAllReplicasAsync(ICouchbaseCollection, string)
CollectionExtensions.GetAllReplicasAsync(ICouchbaseCollection, string, Action<GetAllReplicasOptions>)
CollectionExtensions.GetAndLockAsync(ICouchbaseCollection, string, TimeSpan)
CollectionExtensions.GetAndLockAsync(ICouchbaseCollection, string, TimeSpan, Action<GetAndLockOptions>)
CollectionExtensions.GetAndTouchAsync(ICouchbaseCollection, string, TimeSpan)
CollectionExtensions.GetAndTouchAsync(ICouchbaseCollection, string, TimeSpan, Action<GetAndTouchOptions>)
CollectionExtensions.GetAnyReplicaAsync(ICouchbaseCollection, string)
CollectionExtensions.GetAnyReplicaAsync(ICouchbaseCollection, string, Action<GetAnyReplicaOptions>)
CollectionExtensions.GetAsync(ICouchbaseCollection, string)
CollectionExtensions.GetAsync(ICouchbaseCollection, string, Action<GetOptions>)
CollectionExtensions.InsertAsync<T>(ICouchbaseCollection, string, T)
CollectionExtensions.InsertAsync<T>(ICouchbaseCollection, string, T, Action<InsertOptions>)
CollectionExtensions.List<T>(ICouchbaseCollection, string)
CollectionExtensions.LookupInAllReplicasAsync(ICouchbaseCollection, string, Action<LookupInSpecBuilder>, LookupInAllReplicasOptions?)
CollectionExtensions.LookupInAllReplicasAsync(ICouchbaseCollection, string, Action<LookupInSpecBuilder>, Action<LookupInAllReplicasOptions>)
CollectionExtensions.LookupInAllReplicasAsync(ICouchbaseCollection, string, IEnumerable<LookupInSpec>, Action<LookupInAllReplicasOptions>)
CollectionExtensions.LookupInAnyReplicaAsync(ICouchbaseCollection, string, Action<LookupInSpecBuilder>, LookupInAnyReplicaOptions?)
CollectionExtensions.LookupInAnyReplicaAsync(ICouchbaseCollection, string, Action<LookupInSpecBuilder>, Action<LookupInAnyReplicaOptions>)
CollectionExtensions.LookupInAnyReplicaAsync(ICouchbaseCollection, string, IEnumerable<LookupInSpec>, Action<LookupInAnyReplicaOptions>)
CollectionExtensions.LookupInAsync(ICouchbaseCollection, string, Action<LookupInSpecBuilder>)
CollectionExtensions.LookupInAsync(ICouchbaseCollection, string, Action<LookupInSpecBuilder>, LookupInOptions?)
CollectionExtensions.LookupInAsync(ICouchbaseCollection, string, Action<LookupInSpecBuilder>, Action<LookupInOptions>)
CollectionExtensions.LookupInAsync(ICouchbaseCollection, string, IEnumerable<LookupInSpec>)
CollectionExtensions.LookupInAsync(ICouchbaseCollection, string, IEnumerable<LookupInSpec>, Action<LookupInOptions>)
CollectionExtensions.LookupInAsync<TDocument>(ICouchbaseCollection, string, Action<LookupInSpecBuilder<TDocument>>, LookupInOptions?)
CollectionExtensions.LookupInAsync<TDocument>(ICouchbaseCollection, string, Action<LookupInSpecBuilder<TDocument>>, Action<LookupInOptions>)
CollectionExtensions.MutateInAsync(ICouchbaseCollection, string, Action<MutateInSpecBuilder>)
CollectionExtensions.MutateInAsync(ICouchbaseCollection, string, Action<MutateInSpecBuilder>, MutateInOptions?)
CollectionExtensions.MutateInAsync(ICouchbaseCollection, string, Action<MutateInSpecBuilder>, Action<MutateInOptions>)
CollectionExtensions.MutateInAsync(ICouchbaseCollection, string, IEnumerable<MutateInSpec>)
CollectionExtensions.MutateInAsync(ICouchbaseCollection, string, IEnumerable<MutateInSpec>, Action<MutateInOptions>)
CollectionExtensions.MutateInAsync<TDocument>(ICouchbaseCollection, string, Action<MutateInSpecBuilder<TDocument>>, MutateInOptions?)
CollectionExtensions.MutateInAsync<TDocument>(ICouchbaseCollection, string, Action<MutateInSpecBuilder<TDocument>>, Action<MutateInOptions>)
CollectionExtensions.Queue<T>(ICouchbaseCollection, string, QueueOptions?)
CollectionExtensions.RemoveAsync(ICouchbaseCollection, string)
CollectionExtensions.RemoveAsync(ICouchbaseCollection, string, Action<RemoveOptions>)
CollectionExtensions.ReplaceAsync<T>(ICouchbaseCollection, string, T)
CollectionExtensions.ReplaceAsync<T>(ICouchbaseCollection, string, T, Action<ReplaceOptions>)
CollectionExtensions.Set<T>(ICouchbaseCollection, string)
CollectionExtensions.TouchAsync(ICouchbaseCollection, string, TimeSpan)
CollectionExtensions.TouchAsync(ICouchbaseCollection, string, TimeSpan, Action<TouchOptions>)
CollectionExtensions.TouchWithCasAsync(ICouchbaseCollection, string, TimeSpan)
CollectionExtensions.TouchWithCasAsync(ICouchbaseCollection, string, TimeSpan, Action<TouchOptions>)
CollectionExtensions.TryGetAndLockAsync(ICouchbaseCollection, string, TimeSpan)
CollectionExtensions.TryGetAndLockAsync(ICouchbaseCollection, string, TimeSpan, Action<GetAndLockOptions>)
CollectionExtensions.TryGetAndTouchAsync(ICouchbaseCollection, string, TimeSpan)
CollectionExtensions.TryGetAndTouchAsync(ICouchbaseCollection, string, TimeSpan, GetAndTouchOptions?)
CollectionExtensions.TryGetAndTouchAsync(ICouchbaseCollection, string, TimeSpan, Action<GetAndTouchOptions>)
CollectionExtensions.TryGetAsync(ICouchbaseCollection, string)
CollectionExtensions.TryGetAsync(ICouchbaseCollection, string, Action<GetOptions>)
CollectionExtensions.TryLookupInAsync(ICouchbaseCollection, string, IEnumerable<LookupInSpec>)
CollectionExtensions.TryLookupInAsync(ICouchbaseCollection, string, IEnumerable<LookupInSpec>, Action<LookupInOptions>)
CollectionExtensions.TryRemoveAsync(ICouchbaseCollection, string)
CollectionExtensions.TryRemoveAsync(ICouchbaseCollection, string, Action<RemoveOptions>)
CollectionExtensions.TryReplaceAsync<T>(ICouchbaseCollection, string, T)
CollectionExtensions.TryReplaceAsync<T>(ICouchbaseCollection, string, T, Action<ReplaceOptions>)
CollectionExtensions.TryTouchAsync(ICouchbaseCollection, string, TimeSpan)
CollectionExtensions.TryTouchAsync(ICouchbaseCollection, string, TimeSpan, Action<TouchOptions>)
CollectionExtensions.TryUnlockAsync(ICouchbaseCollection, string, ulong)
CollectionExtensions.TryUnlockAsync(ICouchbaseCollection, string, ulong, Action<UnlockOptions>)
CollectionExtensions.UnlockAsync(ICouchbaseCollection, string, ulong)
CollectionExtensions.UnlockAsync(ICouchbaseCollection, string, ulong, Action<UnlockOptions>)
CollectionExtensions.UnlockAsync<T>(ICouchbaseCollection, string, ulong)
CollectionExtensions.UnlockAsync<T>(ICouchbaseCollection, string, ulong, Action<UnlockOptions>)
CollectionExtensions.UpsertAsync<T>(ICouchbaseCollection, string, T)
CollectionExtensions.UpsertAsync<T>(ICouchbaseCollection, string, T, Action<UpsertOptions>)
  • View Source
In this article
Back to top Copyright © 2020 Couchbase, Inc. All rights reserved.