Class CollectionExtensions
Namespace: Couchbase.KeyValue
Assembly: Couchbase.NetClient.dll
Syntax
public static class CollectionExtensions : object
Methods
| Improve this Doc View SourceDictionary<TValue>(ICouchbaseCollection, String)
Get an IPersistentDictionary<TValue> backed by a given document.
Declaration
public static IPersistentDictionary<TValue> Dictionary<TValue>(this ICouchbaseCollection collection, string docId)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | docId | Document ID which backs the dictionary. |
Returns
Type | Description |
---|---|
IPersistentDictionary<TValue> | The persistent dictionary. |
Type Parameters
Name | Description |
---|---|
TValue |
Remarks
If using a SystemTextJsonSerializer backed by a IDictionary<string, TValue>
in a
ExistsAsync(ICouchbaseCollection, String)
Returns true if a document exists for a given id, otherwise false.
Declaration
public static Task<IExistsResult> ExistsAsync(this ICouchbaseCollection collection, string id)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Returns
Type | Description |
---|---|
Task<IExistsResult> | An asynchronous |
ExistsAsync(ICouchbaseCollection, String, Action<ExistsOptions>)
Returns true if a document exists for a given id, otherwise false.
Declaration
public static Task<IExistsResult> ExistsAsync(this ICouchbaseCollection collection, string id, Action<ExistsOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<ExistsOptions> | configureOptions | Optional parameters |
Returns
Type | Description |
---|---|
Task<IExistsResult> | An asynchronous |
GetAllReplicasAsync(ICouchbaseCollection, String)
Gets a list of document data from the server, leveraging both the active and all available replicas.
Declaration
public static IEnumerable<Task<IGetReplicaResult>> GetAllReplicasAsync(this ICouchbaseCollection collection, string id)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Returns
Type | Description |
---|---|
IEnumerable<Task<IGetReplicaResult>> | An asynchronous |
GetAllReplicasAsync(ICouchbaseCollection, String, Action<GetAllReplicasOptions>)
Gets a list of document data from the server, leveraging both the active and all available replicas.
Declaration
public static IEnumerable<Task<IGetReplicaResult>> GetAllReplicasAsync(this ICouchbaseCollection collection, string id, Action<GetAllReplicasOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<GetAllReplicasOptions> | configureOptions | Optional parameters |
Returns
Type | Description |
---|---|
IEnumerable<Task<IGetReplicaResult>> | An asynchronous |
GetAndLockAsync(ICouchbaseCollection, String, TimeSpan)
Gets a document for a given id and places a pessimistic lock on it for mutations.
Declaration
public static Task<IGetResult> GetAndLockAsync(this ICouchbaseCollection collection, string id, TimeSpan expiry)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
TimeSpan | expiry | The duration of the lock. |
Returns
Type | Description |
---|---|
Task<IGetResult> | An asynchronous |
GetAndLockAsync(ICouchbaseCollection, String, TimeSpan, Action<GetAndLockOptions>)
Gets a document for a given id and places a pessimistic lock on it for mutations.
Declaration
public static Task<IGetResult> GetAndLockAsync(this ICouchbaseCollection collection, string id, TimeSpan expiry, Action<GetAndLockOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
TimeSpan | expiry | The |
Action<GetAndLockOptions> | configureOptions | Any optional parameters. |
Returns
Type | Description |
---|---|
Task<IGetResult> | An asynchronous |
GetAndTouchAsync(ICouchbaseCollection, String, TimeSpan)
Gets a document for a given id and extends its expiration.
Declaration
public static Task<IGetResult> GetAndTouchAsync(this ICouchbaseCollection collection, string id, TimeSpan expiry)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
TimeSpan | expiry | The |
Returns
Type | Description |
---|---|
Task<IGetResult> | An asynchronous |
GetAndTouchAsync(ICouchbaseCollection, String, TimeSpan, Action<GetAndTouchOptions>)
Gets a document for a given id and extends its expiration.
Declaration
public static Task<IGetResult> GetAndTouchAsync(this ICouchbaseCollection collection, string id, TimeSpan expiry, Action<GetAndTouchOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
TimeSpan | expiry | The |
Action<GetAndTouchOptions> | configureOptions | Any optional parameters. |
Returns
Type | Description |
---|---|
Task<IGetResult> | An asynchronous |
GetAnyReplicaAsync(ICouchbaseCollection, String)
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
public static Task<IGetReplicaResult> GetAnyReplicaAsync(this ICouchbaseCollection collection, string id)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Returns
Type | Description |
---|---|
Task<IGetReplicaResult> | An asynchronous |
GetAnyReplicaAsync(ICouchbaseCollection, String, Action<GetAnyReplicaOptions>)
Gets a list of document data from the server, leveraging both the active and all available replicas.
Declaration
public static Task<IGetReplicaResult> GetAnyReplicaAsync(this ICouchbaseCollection collection, string id, Action<GetAnyReplicaOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<GetAnyReplicaOptions> | configureOptions | Optional parameters |
Returns
Type | Description |
---|---|
Task<IGetReplicaResult> | An asynchronous |
GetAsync(ICouchbaseCollection, String)
Fetches a value from the server if it exists. If the document does not exist in the database, a DocumentNotFoundException will be thrown.
Declaration
public static Task<IGetResult> GetAsync(this ICouchbaseCollection collection, string id)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | Primary key as a string. |
Returns
Type | Description |
---|---|
Task<IGetResult> | An asynchronous |
GetAsync(ICouchbaseCollection, String, Action<GetOptions>)
Fetches a value from the server if it exists.If the document does not exist in the database, a DocumentNotFoundException will be thrown.
Declaration
public static Task<IGetResult> GetAsync(this ICouchbaseCollection collection, string id, Action<GetOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | Primary key as a string. |
Action<GetOptions> | configureOptions | Optional parameters. |
Returns
Type | Description |
---|---|
Task<IGetResult> | An asynchronous |
InsertAsync<T>(ICouchbaseCollection, String, T)
Insert a JSON document, failing if it already exists. Maps to Memcached Add command.
Declaration
public static Task<IMutationResult> InsertAsync<T>(this ICouchbaseCollection collection, string id, T content)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
T | content | The content or document body. |
Returns
Type | Description |
---|---|
Task<IMutationResult> | An asynchronous |
Type Parameters
Name | Description |
---|---|
T | The |
InsertAsync<T>(ICouchbaseCollection, String, T, Action<InsertOptions>)
Insert a JSON document, failing if it already exists. Maps to Memcached Add command.
Declaration
public static Task<IMutationResult> InsertAsync<T>(this ICouchbaseCollection collection, string id, T content, Action<InsertOptions> optionsAction)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
T | content | The content or document body. |
Action<InsertOptions> | optionsAction | Any optional parameters. |
Returns
Type | Description |
---|---|
Task<IMutationResult> | An asynchronous |
Type Parameters
Name | Description |
---|---|
T | The |
List<T>(ICouchbaseCollection, String)
Get an IPersistentList<T> backed by a given document.
Declaration
public static IPersistentList<T> List<T>(this ICouchbaseCollection collection, string docId)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | docId | Document ID which backs the list. |
Returns
Type | Description |
---|---|
IPersistentList<T> | The persistent list. |
Type Parameters
Name | Description |
---|---|
T |
Remarks
If using a SystemTextJsonSerializer backed by a
LookupInAllReplicasAsync(ICouchbaseCollection, String, Action<LookupInSpecBuilder>, Action<LookupInAllReplicasOptions>)
Allows the chaining of Sub-Document fetch operations like, Get("path") and Exists("path") into a single atomic fetch, as well as the chaining of option configurations.
Declaration
public static IAsyncEnumerable<ILookupInReplicaResult> LookupInAllReplicasAsync(this ICouchbaseCollection collection, string id, Action<LookupInSpecBuilder> configureBuilder, Action<LookupInAllReplicasOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<LookupInSpecBuilder> | configureBuilder | 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. |
Action<LookupInAllReplicasOptions> | configureOptions | Any optional parameters. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<ILookupInReplicaResult> |
LookupInAllReplicasAsync(ICouchbaseCollection, String, Action<LookupInSpecBuilder>, LookupInAllReplicasOptions)
Allows the chaining of Sub-Document fetch operations like, Get("path") and Exists("path") into a single atomic fetch.
Declaration
public static IAsyncEnumerable<ILookupInReplicaResult> LookupInAllReplicasAsync(this ICouchbaseCollection collection, string id, Action<LookupInSpecBuilder> configureBuilder, LookupInAllReplicasOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<LookupInSpecBuilder> | configureBuilder | 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> |
LookupInAllReplicasAsync(ICouchbaseCollection, String, IEnumerable<LookupInSpec>, Action<LookupInAllReplicasOptions>)
Allows the chaining of option configurations into a single operation.
Declaration
public static IAsyncEnumerable<ILookupInReplicaResult> LookupInAllReplicasAsync(this ICouchbaseCollection collection, string id, IEnumerable<LookupInSpec> specs, Action<LookupInAllReplicasOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
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. |
Action<LookupInAllReplicasOptions> | configureOptions | Any optional parameters. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<ILookupInReplicaResult> |
LookupInAnyReplicaAsync(ICouchbaseCollection, String, Action<LookupInSpecBuilder>, Action<LookupInAnyReplicaOptions>)
Allows the chaining of Sub-Document fetch operations like, Get("path") and Exists("path") into a single atomic fetch, as well as the chaining of option configurations.
Declaration
public static Task<ILookupInReplicaResult> LookupInAnyReplicaAsync(this ICouchbaseCollection collection, string id, Action<LookupInSpecBuilder> configureBuilder, Action<LookupInAnyReplicaOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<LookupInSpecBuilder> | configureBuilder | 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. |
Action<LookupInAnyReplicaOptions> | configureOptions | Any optional parameters. |
Returns
Type | Description |
---|---|
Task<ILookupInReplicaResult> |
LookupInAnyReplicaAsync(ICouchbaseCollection, String, Action<LookupInSpecBuilder>, LookupInAnyReplicaOptions)
Allows the chaining of Sub-Document fetch operations like, Get("path") and Exists("path") into a single atomic fetch.
Declaration
public static Task<ILookupInReplicaResult> LookupInAnyReplicaAsync(this ICouchbaseCollection collection, string id, Action<LookupInSpecBuilder> configureBuilder, LookupInAnyReplicaOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<LookupInSpecBuilder> | configureBuilder | 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> |
LookupInAnyReplicaAsync(ICouchbaseCollection, String, IEnumerable<LookupInSpec>, Action<LookupInAnyReplicaOptions>)
Allows the chaining of option configurations into a single operation.
Declaration
public static Task<ILookupInReplicaResult> LookupInAnyReplicaAsync(this ICouchbaseCollection collection, string id, IEnumerable<LookupInSpec> specs, Action<LookupInAnyReplicaOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
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. |
Action<LookupInAnyReplicaOptions> | configureOptions | Any optional parameters. |
Returns
Type | Description |
---|---|
Task<ILookupInReplicaResult> |
LookupInAsync(ICouchbaseCollection, String, Action<LookupInSpecBuilder>)
Allows the chaining of Sub-Document fetch operations like, Get("path") and Exists("path") into a single atomic fetch.
Declaration
public static Task<ILookupInResult> LookupInAsync(this ICouchbaseCollection collection, string id, Action<LookupInSpecBuilder> configureBuilder)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<LookupInSpecBuilder> | configureBuilder | The builder for chaining sub doc operations - requires at least one: exists, get, count. There is a server enforced maximum of 16 sub document operations allowed per call. |
Returns
Type | Description |
---|---|
Task<ILookupInResult> | An asynchronous |
LookupInAsync(ICouchbaseCollection, String, Action<LookupInSpecBuilder>, Action<LookupInOptions>)
Allows the chaining of Sub-Document fetch operations like, Get("path") and Exists("path") into a single atomic fetch.
Declaration
public static Task<ILookupInResult> LookupInAsync(this ICouchbaseCollection collection, string id, Action<LookupInSpecBuilder> configureBuilder, Action<LookupInOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<LookupInSpecBuilder> | configureBuilder | The builder for chaining sub doc operations - requires at least one: exists, get, count. There is a server enforced maximum of 16 sub document operations allowed per call. |
Action<LookupInOptions> | configureOptions | Any optional parameters. |
Returns
Type | Description |
---|---|
Task<ILookupInResult> | An asynchronous |
LookupInAsync(ICouchbaseCollection, String, Action<LookupInSpecBuilder>, LookupInOptions)
Allows the chaining of Sub-Document fetch operations like, Get("path") and Exists("path") into a single atomic fetch.
Declaration
public static Task<ILookupInResult> LookupInAsync(this ICouchbaseCollection collection, string id, Action<LookupInSpecBuilder> configureBuilder, LookupInOptions options)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<LookupInSpecBuilder> | configureBuilder | The builder for chaining sub doc 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 |
LookupInAsync(ICouchbaseCollection, String, IEnumerable<LookupInSpec>)
Allows the chaining of Sub-Document fetch operations like, Get("path") and Exists("path") into a single atomic fetch.
Declaration
public static Task<ILookupInResult> LookupInAsync(this ICouchbaseCollection collection, string id, IEnumerable<LookupInSpec> specs)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
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. |
Returns
Type | Description |
---|---|
Task<ILookupInResult> | An asynchronous |
LookupInAsync(ICouchbaseCollection, String, IEnumerable<LookupInSpec>, Action<LookupInOptions>)
Allows the chaining of Sub-Document fetch operations like, Get("path") and Exists("path") into a single atomic fetch.
Declaration
public static Task<ILookupInResult> LookupInAsync(this ICouchbaseCollection collection, string id, IEnumerable<LookupInSpec> specs, Action<LookupInOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
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. |
Action<LookupInOptions> | configureOptions | Any optional parameters. |
Returns
Type | Description |
---|---|
Task<ILookupInResult> | An asynchronous |
LookupInAsync<TDocument>(ICouchbaseCollection, String, Action<LookupInSpecBuilder<TDocument>>, Action<LookupInOptions>)
Allows the chaining of Sub-Document fetch operations like, Get("path") and Exists("path") into a single atomic fetch. The result is strongly typed.
Declaration
public static Task<ILookupInResult<TDocument>> LookupInAsync<TDocument>(this ICouchbaseCollection collection, string id, Action<LookupInSpecBuilder<TDocument>> configureBuilder, Action<LookupInOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<LookupInSpecBuilder<TDocument>> | configureBuilder | An array of fetch operations - requires at least one: exists, get, count. |
Action<LookupInOptions> | configureOptions | Any optional parameters. |
Returns
Type | Description |
---|---|
Task<ILookupInResult<TDocument>> | An asynchronous |
Type Parameters
Name | Description |
---|---|
TDocument | The document |
LookupInAsync<TDocument>(ICouchbaseCollection, String, Action<LookupInSpecBuilder<TDocument>>, LookupInOptions)
Allows the chaining of Sub-Document fetch operations like, Get("path") and Exists("path") into a single atomic fetch. The result is strongly typed.
Declaration
public static async Task<ILookupInResult<TDocument>> LookupInAsync<TDocument>(this ICouchbaseCollection collection, string id, Action<LookupInSpecBuilder<TDocument>> configureBuilder, LookupInOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<LookupInSpecBuilder<TDocument>> | configureBuilder | An array of fetch operations - requires at least one: exists, get, count. |
LookupInOptions | options | Any optional parameters. |
Returns
Type | Description |
---|---|
Task<ILookupInResult<TDocument>> | An asynchronous |
Type Parameters
Name | Description |
---|---|
TDocument | The document |
MutateInAsync(ICouchbaseCollection, String, Action<MutateInSpecBuilder>)
Allows the chaining of Sub-Document mutation operations on a specific document in a single atomic transaction.
Declaration
public static Task<IMutateInResult> MutateInAsync(this ICouchbaseCollection collection, string id, Action<MutateInSpecBuilder> configureBuilder)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<MutateInSpecBuilder> | configureBuilder | An array of mutation Sub-Document operations: Iinsert, Upsert, Replace, Remove, ArrayPrepend, ArrayAppend, ArrayInsert, ArrayAddUnique, Increment and/or Decrement. |
Returns
Type | Description |
---|---|
Task<IMutateInResult> | An asynchronous |
MutateInAsync(ICouchbaseCollection, String, Action<MutateInSpecBuilder>, Action<MutateInOptions>)
Allows the chaining of Sub-Document mutation operations on a specific document in a single atomic transaction.
Declaration
public static Task<IMutateInResult> MutateInAsync(this ICouchbaseCollection collection, string id, Action<MutateInSpecBuilder> configureBuilder, Action<MutateInOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<MutateInSpecBuilder> | configureBuilder | An array of mutation Sub-Document operations: Insert, Upsert, Replace, Remove, ArrayPrepend, ArrayAppend, ArrayInsert, ArrayAddUnique, Increment and/or Decrement. |
Action<MutateInOptions> | configureOptions | Any optional parameters. |
Returns
Type | Description |
---|---|
Task<IMutateInResult> | An asynchronous |
MutateInAsync(ICouchbaseCollection, String, Action<MutateInSpecBuilder>, MutateInOptions)
Allows the chaining of Sub-Document mutation operations on a specific document in a single atomic transaction.
Declaration
public static Task<IMutateInResult> MutateInAsync(this ICouchbaseCollection collection, string id, Action<MutateInSpecBuilder> configureBuilder, MutateInOptions options)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<MutateInSpecBuilder> | configureBuilder | An array of mutation Sub-Document operations: Insert, Upsert, Replace, Remove, ArrayPrepend, ArrayAppend, ArrayInsert, ArrayAddUnique, Increment and/or Decrement. |
MutateInOptions | options | Any optional parameters. |
Returns
Type | Description |
---|---|
Task<IMutateInResult> | An asynchronous |
MutateInAsync(ICouchbaseCollection, String, IEnumerable<MutateInSpec>)
Allows the chaining of Sub-Document mutation operations on a specific document in a single atomic transaction.
Declaration
public static Task<IMutateInResult> MutateInAsync(this ICouchbaseCollection collection, string id, IEnumerable<MutateInSpec> specs)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
IEnumerable<MutateInSpec> | specs | An array of mutation Sub-Document operations: Insert, Upsert, Replace, Remove, ArrayPrepend, ArrayAppend, ArrayInsert, ArrayAddUnique, Increment and/or Decrement. |
Returns
Type | Description |
---|---|
Task<IMutateInResult> | An asynchronous |
MutateInAsync(ICouchbaseCollection, String, IEnumerable<MutateInSpec>, Action<MutateInOptions>)
Allows the chaining of Sub-Document mutation operations on a specific document in a single atomic transaction.
Declaration
public static Task<IMutateInResult> MutateInAsync(this ICouchbaseCollection collection, string id, IEnumerable<MutateInSpec> specs, Action<MutateInOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
IEnumerable<MutateInSpec> | specs | An array of mutation Sub-Document operations: Insert, Upsert, Replace, Remove, ArrayPrepend, ArrayAppend, ArrayInsert, ArrayAddUnique, Increment and/or Decrement. |
Action<MutateInOptions> | configureOptions | Any optional parameters. |
Returns
Type | Description |
---|---|
Task<IMutateInResult> | An asynchronous |
MutateInAsync<TDocument>(ICouchbaseCollection, String, Action<MutateInSpecBuilder<TDocument>>, Action<MutateInOptions>)
Allows the chaining of Sub-Document fetch operations like, Get("path") and Exists("path") into a single atomic fetch. The result is strongly typed.
Declaration
public static Task<IMutateInResult<TDocument>> MutateInAsync<TDocument>(this ICouchbaseCollection collection, string id, Action<MutateInSpecBuilder<TDocument>> configureBuilder, Action<MutateInOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<MutateInSpecBuilder<TDocument>> | configureBuilder | An array of fetch operations - requires at least one: exists, get, count. |
Action<MutateInOptions> | configureOptions | Any optional parameters. |
Returns
Type | Description |
---|---|
Task<IMutateInResult<TDocument>> | An asynchronous |
Type Parameters
Name | Description |
---|---|
TDocument | The document |
MutateInAsync<TDocument>(ICouchbaseCollection, String, Action<MutateInSpecBuilder<TDocument>>, MutateInOptions)
Allows the chaining of Sub-Document fetch operations like, Get("path") and Exists("path") into a single atomic fetch. The result is strongly typed.
Declaration
public static async Task<IMutateInResult<TDocument>> MutateInAsync<TDocument>(this ICouchbaseCollection collection, string id, Action<MutateInSpecBuilder<TDocument>> configureBuilder, MutateInOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<MutateInSpecBuilder<TDocument>> | configureBuilder | An array of fetch operations - requires at least one: exists, get, count. |
MutateInOptions | options | Any optional parameters. |
Returns
Type | Description |
---|---|
Task<IMutateInResult<TDocument>> | An asynchronous |
Type Parameters
Name | Description |
---|---|
TDocument | The document |
Queue<T>(ICouchbaseCollection, String, QueueOptions)
Get an IPersistentQueue<T> backed by a given document.
Declaration
public static IPersistentQueue<T> Queue<T>(this ICouchbaseCollection collection, string docId, QueueOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | docId | Document ID which backs the queue. |
QueueOptions | options | Behavior options for the queue implementation. |
Returns
Type | Description |
---|---|
IPersistentQueue<T> | The persistent queue. |
Type Parameters
Name | Description |
---|---|
T |
Remarks
If using a SystemTextJsonSerializer backed by a
RemoveAsync(ICouchbaseCollection, String)
Removes an existing document in Couchbase server, failing if it does not exist.
Declaration
public static Task RemoveAsync(this ICouchbaseCollection collection, string id)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Returns
Type | Description |
---|---|
Task | An asynchronous |
RemoveAsync(ICouchbaseCollection, String, Action<RemoveOptions>)
Removes an existing document in Couchbase server, failing if it does not exist.
Declaration
public static Task RemoveAsync(this ICouchbaseCollection collection, string id, Action<RemoveOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
Action<RemoveOptions> | configureOptions | Any optional parameters. |
Returns
Type | Description |
---|---|
Task | An asynchronous |
ReplaceAsync<T>(ICouchbaseCollection, String, T)
Replaces an existing document in Couchbase server, failing if it does not exist. Maps to Memcached SET command.
Declaration
public static Task<IMutationResult> ReplaceAsync<T>(this ICouchbaseCollection collection, string id, T content)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
T | content | The content or document body. |
Returns
Type | Description |
---|---|
Task<IMutationResult> | An asynchronous |
Type Parameters
Name | Description |
---|---|
T | The |
ReplaceAsync<T>(ICouchbaseCollection, String, T, Action<ReplaceOptions>)
Replaces an existing document in Couchbase server, failing if it does not exist. Maps to Memcached SET command.
Declaration
public static Task<IMutationResult> ReplaceAsync<T>(this ICouchbaseCollection collection, string id, T content, Action<ReplaceOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
T | content | The content or document body. |
Action<ReplaceOptions> | configureOptions | Any optional parameters. |
Returns
Type | Description |
---|---|
Task<IMutationResult> | An asynchronous |
Type Parameters
Name | Description |
---|---|
T | The |
Set<T>(ICouchbaseCollection, String)
Get an IPersistentSet<TValue> backed by a given document.
Declaration
public static IPersistentSet<T> Set<T>(this ICouchbaseCollection collection, string docId)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | docId | Document ID which backs the set. |
Returns
Type | Description |
---|---|
IPersistentSet<T> | The persistent set. |
Type Parameters
Name | Description |
---|---|
T |
Remarks
If using a SystemTextJsonSerializer backed by a
TouchAsync(ICouchbaseCollection, String, TimeSpan)
Updates the expiration a document given an id, without modifying or returning its value.
Declaration
public static Task TouchAsync(this ICouchbaseCollection collection, string id, TimeSpan expiry)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
TimeSpan | expiry | The |
Returns
Type | Description |
---|---|
Task | An asynchronous |
TouchAsync(ICouchbaseCollection, String, TimeSpan, Action<TouchOptions>)
Updates the expiration a document given an id, without modifying or returning its value.
Declaration
public static Task TouchAsync(this ICouchbaseCollection collection, string id, TimeSpan expiry, Action<TouchOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
TimeSpan | expiry | The |
Action<TouchOptions> | configureOptions | Any optional parameters. |
Returns
Type | Description |
---|---|
Task | An asynchronous |
TouchWithCasAsync(ICouchbaseCollection, String, TimeSpan)
Updates the expiration a document given an id, without modifying or returning its value.
Declaration
public static Task<IMutationResult> TouchWithCasAsync(this ICouchbaseCollection collection, string id, TimeSpan expiry)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
TimeSpan | expiry | The |
Returns
Type | Description |
---|---|
Task<IMutationResult> | An asynchronous |
TouchWithCasAsync(ICouchbaseCollection, String, TimeSpan, Action<TouchOptions>)
Updates the expiration a document given an id, without modifying or returning its value.
Declaration
public static Task<IMutationResult> TouchWithCasAsync(this ICouchbaseCollection collection, string id, TimeSpan expiry, Action<TouchOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
TimeSpan | expiry | The |
Action<TouchOptions> | configureOptions | Any optional parameters. |
Returns
Type | Description |
---|---|
Task<IMutationResult> | An asynchronous |
TryGetAndLockAsync(ICouchbaseCollection, String, TimeSpan)
Given an id, gets a document from the database and places a pessimistic lock on it for mutations. If the key is not found, a ITryGetResult will be returned with the Exists property set to false; otherwise true. Any other failure will result in a thrown exception.
Declaration
public static async Task<ITryGetResult> TryGetAndLockAsync(this ICouchbaseCollection collection, string id, TimeSpan expires)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | The ICouchbaseCollection where the key is found. |
String | id | The identifier for the document. |
TimeSpan | expires |
Returns
Type | Description |
---|---|
Task<ITryGetResult> | A ITryGetResult with its Exists property set; note that if false and ContentAs() is called, a DocumentNotFoundException will be thrown. |
TryGetAndLockAsync(ICouchbaseCollection, String, TimeSpan, Action<GetAndLockOptions>)
Given an id, gets a document from the database and places a pessimistic lock on it for mutations. If the key is not found, a ITryGetResult will be returned with the Exists property set to false; otherwise true. Any other failure will result in a thrown exception.
Declaration
public static async Task<ITryGetResult> TryGetAndLockAsync(this ICouchbaseCollection collection, string id, TimeSpan expires, Action<GetAndLockOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | The ICouchbaseCollection where the key is found. |
String | id | The identifier for the document. |
TimeSpan | expires | |
Action<GetAndLockOptions> | configureOptions | The GetOptions to be passed to the server. |
Returns
Type | Description |
---|---|
Task<ITryGetResult> | A ITryGetResult with its Exists property set; note that if false and ContentAs() is called, a DocumentNotFoundException will be thrown. |
TryGetAndTouchAsync(ICouchbaseCollection, String, TimeSpan)
Given an id, gets a document from the database. If the key is not found, a ITryGetResult will be returned with the Exists property set to false; otherwise true. Any other failure will result in a thrown exception.
Declaration
public static async Task<ITryGetResult> TryGetAndTouchAsync(this ICouchbaseCollection collection, string id, TimeSpan expires)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | The ICouchbaseCollection where the key is found. |
String | id | The identifier for the document. |
TimeSpan | expires |
Returns
Type | Description |
---|---|
Task<ITryGetResult> | A ITryGetResult with its Exists property set; note that if false and ContentAs() is called, a DocumentNotFoundException will be thrown. |
TryGetAndTouchAsync(ICouchbaseCollection, String, TimeSpan, Action<GetAndTouchOptions>)
Given an id, gets a document from the database. If the key is not found, a ITryGetResult will be returned with the Exists property set to false; otherwise true. Any other failure will result in a thrown exception.
Declaration
public static async Task<ITryGetResult> TryGetAndTouchAsync(this ICouchbaseCollection collection, string id, TimeSpan expires, Action<GetAndTouchOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | The ICouchbaseCollection where the key is found. |
String | id | The identifier for the document. |
TimeSpan | expires | |
Action<GetAndTouchOptions> | configureOptions | The GetOptions to be passed to the server. |
Returns
Type | Description |
---|---|
Task<ITryGetResult> | A ITryGetResult with its Exists property set; note that if false and ContentAs() is called, a DocumentNotFoundException will be thrown. |
TryGetAndTouchAsync(ICouchbaseCollection, String, TimeSpan, GetAndTouchOptions)
Given an id, gets a document from the database. If the key is not found, a ITryGetResult will be returned with the Exists property set to false; otherwise true. Any other failure will result in a thrown exception.
Declaration
public static async Task<ITryGetResult> TryGetAndTouchAsync(this ICouchbaseCollection collection, string id, TimeSpan expires, GetAndTouchOptions configureOptions = null)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | The ICouchbaseCollection where the key is found. |
String | id | The identifier for the document. |
TimeSpan | expires | |
GetAndTouchOptions | configureOptions | The GetOptions to be passed to the server. |
Returns
Type | Description |
---|---|
Task<ITryGetResult> | A ITryGetResult with its Exists property set; note that if false and ContentAs() is called, a DocumentNotFoundException will be thrown. |
TryGetAsync(ICouchbaseCollection, String)
Given an id, gets a document from the database. If the key is not found, a ITryGetResult will be returned with the Exists property set to false; otherwise true.
Declaration
public static async Task<ITryGetResult> TryGetAsync(this ICouchbaseCollection collection, string id)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | The ICouchbaseCollection where the key is found. |
String | id | The identifier for the document. |
Returns
Type | Description |
---|---|
Task<ITryGetResult> | A ITryGetResult with its Exists property set; note that if false and ContentAs() is called, a DocumentNotFoundException will be thrown. |
TryGetAsync(ICouchbaseCollection, String, Action<GetOptions>)
Given an id, gets a document from the database. If the key is not found, a ITryGetResult will be returned with the Exists property set to false; otherwise true.
Declaration
public static async Task<ITryGetResult> TryGetAsync(this ICouchbaseCollection collection, string id, Action<GetOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | The ICouchbaseCollection where the key is found. |
String | id | The identifier for the document. |
Action<GetOptions> | configureOptions | The GetOptions to be passed to the server. |
Returns
Type | Description |
---|---|
Task<ITryGetResult> | A ITryGetResult with its Exists property set; note that if false and ContentAs() is called, a DocumentNotFoundException will be thrown. |
TryRemoveAsync(ICouchbaseCollection, String)
Given an id, removes a document from the database. If the key is not found, a ITryRemoveResult will be returned with the Exists property set to false; otherwise true. Any other failure will result in a thrown exception.
Declaration
public static async Task<ITryRemoveResult> TryRemoveAsync(this ICouchbaseCollection collection, string id)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | The ICouchbaseCollection where the key is found. |
String | id | The identifier for the document. |
Returns
Type | Description |
---|---|
Task<ITryRemoveResult> | A ITryRemoveResult with its Exists property set to true if the document was removed and false if the server returns KeyNotFound. |
TryRemoveAsync(ICouchbaseCollection, String, Action<RemoveOptions>)
Given an id, removes a document from the database. If the key is not found, a ITryRemoveResult will be returned with the Exists property set to false; otherwise true. Any other failure will result in a thrown exception.
Declaration
public static async Task<ITryRemoveResult> TryRemoveAsync(this ICouchbaseCollection collection, string id, Action<RemoveOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | The ICouchbaseCollection where the key is found. |
String | id | The identifier for the document. |
Action<RemoveOptions> | configureOptions | The RemoveOptions to be passed to the server. |
Returns
Type | Description |
---|---|
Task<ITryRemoveResult> | A ITryRemoveResult with its Exists property set to true if the document was removed and false if the server returns KeyNotFound. |
TryReplaceAsync<T>(ICouchbaseCollection, String, T)
Given an id, replaces a document from the database. If the key is not found, a ITryMutationResult will be returned with the Exists property set to false; otherwise true. Any other failure will result in a thrown exception.
Declaration
public static async Task<ITryMutationResult> TryReplaceAsync<T>(this ICouchbaseCollection collection, string id, T content)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | The ICouchbaseCollection where the key is found. |
String | id | The identifier for the document. |
T | content | The document or content to store in the database. |
Returns
Type | Description |
---|---|
Task<ITryMutationResult> | A ITryMutationResult with its Exists property set to true if the server replaces the document and false if the server returns KeyNotFound. |
Type Parameters
Name | Description |
---|---|
T |
TryReplaceAsync<T>(ICouchbaseCollection, String, T, Action<ReplaceOptions>)
Given an id, replaces a document from the database. If the key is not found, a ITryMutationResult will be returned with the Exists property set to false; otherwise true. Any other failure will result in a thrown exception.
Declaration
public static async Task<ITryMutationResult> TryReplaceAsync<T>(this ICouchbaseCollection collection, string id, T content, Action<ReplaceOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | The ICouchbaseCollection where the key is found. |
String | id | The identifier for the document. |
T | content | The document or content to store in the database. |
Action<ReplaceOptions> | configureOptions | The RemoveOptions to be passed to the server. |
Returns
Type | Description |
---|---|
Task<ITryMutationResult> | A ITryMutationResult with its Exists property set to true if the server replaces the document and false if the server returns KeyNotFound. |
Type Parameters
Name | Description |
---|---|
T |
TryTouchAsync(ICouchbaseCollection, String, TimeSpan)
Given an id, updates a documents expiry in the database. If the key is not found, a ITryTouchResult will be returned with the Exists property set to false; otherwise true. Any other failure will result in a thrown exception.
Declaration
public static async Task<ITryTouchResult> TryTouchAsync(this ICouchbaseCollection collection, string id, TimeSpan expiry)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | The ICouchbaseCollection where the key is found. |
String | id | The identifier for the document. |
TimeSpan | expiry | A |
Returns
Type | Description |
---|---|
Task<ITryTouchResult> | A ITryTouchResult with its Exists property set to true if the server returns success and false if the server returns KeyNotFound. |
TryTouchAsync(ICouchbaseCollection, String, TimeSpan, Action<TouchOptions>)
Given an id, updates a documents expiry in the database. If the key is not found, a ITryTouchResult will be returned with the Exists property set to false; otherwise true. Any other failure will result in a thrown exception.
Declaration
public static async Task<ITryTouchResult> TryTouchAsync(this ICouchbaseCollection collection, string id, TimeSpan expiry, Action<TouchOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | The ICouchbaseCollection where the key is found. |
String | id | The identifier for the document. |
TimeSpan | expiry | A |
Action<TouchOptions> | configureOptions | The RemoveOptions to be passed to the server. |
Returns
Type | Description |
---|---|
Task<ITryTouchResult> | A ITryTouchResult with its Exists property set to true if the server returns success and false if the server returns KeyNotFound. |
TryUnlockAsync(ICouchbaseCollection, String, UInt64)
Given an id, unlocks a document from the database. If the key is not found, a ITryUnlockResult will be returned with the Exists property set to false; otherwise true. Any other failure will result in a thrown exception.
Declaration
public static async Task<ITryUnlockResult> TryUnlockAsync(this ICouchbaseCollection collection, string id, ulong cas)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | The ICouchbaseCollection where the key is found. |
String | id | The identifier for the document. |
UInt64 | cas | The Compare And Swap (CAS) of the document. |
Returns
Type | Description |
---|---|
Task<ITryUnlockResult> | A ITryUnlockResult with its Exists property set to true if the server returns success and false if the server returns KeyNotFound. |
TryUnlockAsync(ICouchbaseCollection, String, UInt64, Action<UnlockOptions>)
Given an id, unlocks a document from the database. If the key is not found, a ITryUnlockResult will be returned with the Exists property set to false; otherwise true. Any other failure will result in a thrown exception.
Declaration
public static async Task<ITryUnlockResult> TryUnlockAsync(this ICouchbaseCollection collection, string id, ulong cas, Action<UnlockOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | The ICouchbaseCollection where the key is found. |
String | id | The identifier for the document. |
UInt64 | cas | The Compare And Swap (CAS) of the document. |
Action<UnlockOptions> | configureOptions | The RemoveOptions to be passed to the server. |
Returns
Type | Description |
---|---|
Task<ITryUnlockResult> | A ITryUnlockResult with its Exists property set to true if the server returns success and false if the server returns KeyNotFound. |
UnlockAsync(ICouchbaseCollection, String, UInt64)
Unlocks a document pessimistically locked by a GetAndLock operation.
Declaration
public static Task UnlockAsync(this ICouchbaseCollection collection, string id, ulong cas)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
UInt64 | cas | The CAS from the GetAndLock operation. |
Returns
Type | Description |
---|---|
Task | An asynchronous |
UnlockAsync(ICouchbaseCollection, String, UInt64, Action<UnlockOptions>)
Unlocks a document pessimistically locked by a GetAndLock operation.
Declaration
public static Task UnlockAsync(this ICouchbaseCollection collection, string id, ulong cas, Action<UnlockOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
UInt64 | cas | The CAS from the GetAndLock operation. |
Action<UnlockOptions> | configureOptions | Any optional parameters. |
Returns
Type | Description |
---|---|
Task | An asynchronous |
UnlockAsync<T>(ICouchbaseCollection, String, UInt64)
Declaration
public static Task UnlockAsync<T>(this ICouchbaseCollection collection, string id, ulong cas)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | |
String | id | |
UInt64 | cas |
Returns
Type | Description |
---|---|
Task |
Type Parameters
Name | Description |
---|---|
T |
UnlockAsync<T>(ICouchbaseCollection, String, UInt64, Action<UnlockOptions>)
Declaration
public static Task UnlockAsync<T>(this ICouchbaseCollection collection, string id, ulong cas, Action<UnlockOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | |
String | id | |
UInt64 | cas | |
Action<UnlockOptions> | configureOptions |
Returns
Type | Description |
---|---|
Task |
Type Parameters
Name | Description |
---|---|
T |
UpsertAsync<T>(ICouchbaseCollection, String, T)
Insert a new document or overwrite an existing document in Couchbase server. Maps to Memcached Set command.
Declaration
public static Task<IMutationResult> UpsertAsync<T>(this ICouchbaseCollection collection, string id, T content)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
T | content | The content or document body. |
Returns
Type | Description |
---|---|
Task<IMutationResult> | An asynchronous |
Type Parameters
Name | Description |
---|---|
T | The |
UpsertAsync<T>(ICouchbaseCollection, String, T, Action<UpsertOptions>)
Insert a new document or overwrite an existing document in Couchbase server. Maps to Memcached Set command.
Declaration
public static Task<IMutationResult> UpsertAsync<T>(this ICouchbaseCollection collection, string id, T content, Action<UpsertOptions> configureOptions)
Parameters
Type | Name | Description |
---|---|---|
ICouchbaseCollection | collection | Couchbase collection. |
String | id | The id of the document. |
T | content | The content or document body. |
Action<UpsertOptions> | configureOptions | Optional parameters |
Returns
Type | Description |
---|---|
Task<IMutationResult> | An asynchronous |
Type Parameters
Name | Description |
---|---|
T | The |