Interface ICouchbaseCollection
Represents a collection of JSON objects in Couchbase.
Namespace: Couchbase.KeyValue
Assembly: Couchbase.NetClient.dll
Syntax
public interface ICouchbaseCollection
Properties
| Edit this page View SourceBinary
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 |
Cid
The identifier for the collection.
Declaration
uint? Cid { get; }
Property Value
Type | Description |
---|---|
uint? |
IsDefaultCollection
Returns true if this is the default collection in the default scope.
Declaration
bool IsDefaultCollection { get; }
Property Value
Type | Description |
---|---|
bool |
Name
The name of the collection.
Declaration
string Name { get; }
Property Value
Type | Description |
---|---|
string |
QueryIndexes
Provides access to the indexes at the Collection level.
Declaration
[InterfaceStability(Level.Volatile)]
ICollectionQueryIndexManager QueryIndexes { get; }
Property Value
Type | Description |
---|---|
ICollectionQueryIndexManager |
Scope
Scope which owns this collection.
Declaration
IScope Scope { get; }
Property Value
Type | Description |
---|---|
IScope |
Methods
| Edit this page View SourceExistsAsync(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. |
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. |
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.
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. |
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. |
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. |
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. |
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> |
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> |
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. |
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. |
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. |
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. |
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> |
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. |
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. |
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. |
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 |
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. |