Class CollectionExtensions
Inherited Members
Namespace: Couchbase.KeyValue
Assembly: Couchbase.NetClient.dll
Syntax
public static class CollectionExtensions
Methods
| Edit this page 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 JsonSerializerContext,
be sure to include IDictionary<string, TValue> in a JsonSerializableAttribute on the context.
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 Task containing an IExistsResult object with a boolean value indicating the presence of the document. |
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 Task containing an IExistsResult object with a boolean value indicating the presence of the document. |
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 Task containing the JSON object or scalar encapsulated in a list of IGetReplicaResult API objects. |
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 Task containing the JSON object or scalar encapsulated in a list of IGetReplicaResult API objects. |
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 Task The JSON object or scalar encapsulated in a IGetResult API object. |
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 TimeSpan expiry of the new expiration time. |
| Action<GetAndLockOptions> | configureOptions | Any optional parameters. |
Returns
| Type | Description |
|---|---|
| Task<IGetResult> | An asynchronous Task The JSON object or scalar encapsulated in a IGetResult API object. |
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 TimeSpan expiry of the new expiration time. |
Returns
| Type | Description |
|---|---|
| Task<IGetResult> | An asynchronous Task The JSON object or scalar encapsulated in a IGetResult API object. |
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 TimeSpan expiry of the new expiration time. |
| Action<GetAndTouchOptions> | configureOptions | Any optional parameters. |
Returns
| Type | Description |
|---|---|
| Task<IGetResult> | An asynchronous Task The JSON object or scalar encapsulated in a IGetResult API object. |
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 Task The JSON object or scalar encapsulated in a IGetReplicaResult API object. |
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 Task containing the JSON object or scalar encapsulated in a list of IGetReplicaResult API objects. |
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 Task containing the JSON object or scalar encapsulated in an IGetResult API object. |
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 Task containing the JSON object or scalar encapsulated in an IGetResult API object. |
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 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. |
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 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. |
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 JsonSerializerContext, be sure to include IList<T> in a JsonSerializableAttribute on the context.
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, 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
[InterfaceStability(Level.Volatile)]
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, IEnumerable<LookupInSpec>, Action<LookupInAllReplicasOptions>)
Allows the chaining of option configurations into a single operation.
Declaration
[InterfaceStability(Level.Volatile)]
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>, LookupInAnyReplicaOptions?)
Allows the chaining of Sub-Document fetch operations like, Get("path") and Exists("path") into a single atomic fetch.
Declaration
[InterfaceStability(Level.Volatile)]
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, 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
[InterfaceStability(Level.Volatile)]
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, IEnumerable<LookupInSpec>, Action<LookupInAnyReplicaOptions>)
Allows the chaining of option configurations into a single operation.
Declaration
[InterfaceStability(Level.Volatile)]
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 Task containing the results of the lookup as an ILookupInResult object. |
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 Task containing the results of the lookup as an ILookupInResult object. |
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 Task containing the results of the lookup as an ILookupInResult object. |
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 Task containing the results of the lookup as an ILookupInResult object. |
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 Task containing the results of the lookup as an ILookupInResult object. |
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
[InterfaceStability(Level.Volatile)]
public static 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 Task containing the results of the lookup as an ILookupInResult of type T. |
Type Parameters
| Name | Description |
|---|---|
| TDocument | The document Type. |
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
[InterfaceStability(Level.Volatile)]
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 Task containing the results of the lookup as an ILookupInResult of type T. |
Type Parameters
| Name | Description |
|---|---|
| TDocument | The document Type. |
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 Task containing the results of the mutation as an IMutateInResult object. |
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 Task containing the results of the mutation as an IMutateInResult object. |
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 Task containing the results of the mutation as an IMutateInResult object. |
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 Task containing the results of the mutation as an IMutateInResult object. |
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 Task containing the results of the mutation as an IMutateInResult object. |
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
[InterfaceStability(Level.Volatile)]
public static 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 Task containing the results of the lookup as an ILookupInResult of type T. |
Type Parameters
| Name | Description |
|---|---|
| TDocument | The document Type. |
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
[InterfaceStability(Level.Volatile)]
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 Task containing the results of the lookup as an ILookupInResult of type T. |
Type Parameters
| Name | Description |
|---|---|
| TDocument | The document Type. |
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 JsonSerializerContext, be sure to include IList<T> in a JsonSerializableAttribute on the context.
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 Task object for awaiting. |
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 Task object for awaiting. |
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 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. |
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 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. |
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 JsonSerializerContext, be sure to include ISet<T> in a JsonSerializableAttribute on the context.
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 TimeSpan expiry of the new expiration time. |
Returns
| Type | Description |
|---|---|
| Task | An asynchronous Task object for awaiting. |
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 TimeSpan expiry of the new expiration time. |
| Action<TouchOptions> | configureOptions | Any optional parameters. |
Returns
| Type | Description |
|---|---|
| Task | An asynchronous Task object for awaiting. |
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 TimeSpan expiry of the new expiration time. |
Returns
| Type | Description |
|---|---|
| Task<IMutationResult> | An asynchronous Task object for awaiting, with a IMutationResult containing a Cas value. |
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 TimeSpan expiry of the new expiration time. |
| Action<TouchOptions> | configureOptions | Any optional parameters. |
Returns
| Type | Description |
|---|---|
| Task<IMutationResult> | An asynchronous Task object for awaiting, with a IMutationResult containing a Cas value. |
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 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 DocumentExists 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 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 DocumentExists 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 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 DocumentExists 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 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 DocumentExists 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 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 DocumentExists property set; note that if false and ContentAs() is called, a DocumentNotFoundException will be thrown. |
TryGetAsync(ICouchbaseCollection, string)
Allows the chaining of Sub-Document fetch operations like, Get("path") and Exists("path") into a single atomic fetch. If the document is not found, a ITryLookupInResult will be returned with the DocumentExists property set to false; otherwise true.
Declaration
public static 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 DocumentExists 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 DocumentExists property set to false; otherwise true.
Declaration
public static 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 DocumentExists property set; note that if false and ContentAs() is called, a DocumentNotFoundException will be thrown. |
TryLookupInAsync(ICouchbaseCollection, string, IEnumerable<LookupInSpec>)
Allows the chaining of Sub-Document fetch operations like, Get("path") and Exists("path") into a single atomic fetch. If the document is not found, a ITryLookupInResult will be returned with the DocumentExists property set to false; otherwise true.
Declaration
public static Task<ITryLookupInResult> TryLookupInAsync(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<ITryLookupInResult> | An asynchronous Task containing the results of the lookup as an ITryLookupInResult object with its DocumentExists property set; note that if false and ContentAs() is called, a DocumentNotFoundException |
TryLookupInAsync(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<ITryLookupInResult> TryLookupInAsync(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 | The LookupInOptions to be passed into the server. |
Returns
| Type | Description |
|---|---|
| Task<ITryLookupInResult> | An asynchronous Task containing the results of the lookup as an ITryLookupInResult object with its DocumentExists property set; note that if false and ContentAs() is called, a DocumentNotFoundException |
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 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 DocumentExists 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 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 DocumentExists 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 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 DocumentExists 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 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 DocumentExists 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 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 TimeSpan with the duration of the expiry. |
Returns
| Type | Description |
|---|---|
| Task<ITryTouchResult> | A ITryTouchResult with its DocumentExists 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 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 TimeSpan with the duration of the expiry. |
| Action<TouchOptions> | configureOptions | The RemoveOptions to be passed to the server. |
Returns
| Type | Description |
|---|---|
| Task<ITryTouchResult> | A ITryTouchResult with its DocumentExists property set to true if the server returns success and false if the server returns KeyNotFound. |
TryUnlockAsync(ICouchbaseCollection, string, ulong)
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 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. |
| ulong | cas | The Compare And Swap (CAS) of the document. |
Returns
| Type | Description |
|---|---|
| Task<ITryUnlockResult> | A ITryUnlockResult with its DocumentExists property set to true if the server returns success and false if the server returns KeyNotFound. |
TryUnlockAsync(ICouchbaseCollection, string, ulong, 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 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. |
| ulong | 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 DocumentExists property set to true if the server returns success and false if the server returns KeyNotFound. |
UnlockAsync(ICouchbaseCollection, string, ulong)
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. |
| ulong | cas | The CAS from the GetAndLock operation. |
Returns
| Type | Description |
|---|---|
| Task | An asynchronous Task object for awaiting. |
UnlockAsync(ICouchbaseCollection, string, ulong, 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. |
| ulong | cas | The CAS from the GetAndLock operation. |
| Action<UnlockOptions> | configureOptions | Any optional parameters. |
Returns
| Type | Description |
|---|---|
| Task | An asynchronous Task object for awaiting. |
UnlockAsync<T>(ICouchbaseCollection, string, ulong)
Declaration
[Obsolete("Use overload that does not have a Type parameter T.")]
public static Task UnlockAsync<T>(this ICouchbaseCollection collection, string id, ulong cas)
Parameters
| Type | Name | Description |
|---|---|---|
| ICouchbaseCollection | collection | |
| string | id | |
| ulong | cas |
Returns
| Type | Description |
|---|---|
| Task |
Type Parameters
| Name | Description |
|---|---|
| T |
UnlockAsync<T>(ICouchbaseCollection, string, ulong, Action<UnlockOptions>)
Declaration
[Obsolete("Use overload that does not have a Type parameter T.")]
public static Task UnlockAsync<T>(this ICouchbaseCollection collection, string id, ulong cas, Action<UnlockOptions> configureOptions)
Parameters
| Type | Name | Description |
|---|---|---|
| ICouchbaseCollection | collection | |
| string | id | |
| ulong | 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 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. |
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 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. |