The Remove() method deletes an item in
the database with the specified key.
| API Call | object.Remove(key) | ||
| Asynchronous | no | ||
| Description | Delete a key/value | ||
| Returns | Object; supported values: | ||
COUCHBASE_ETMPFAIL | Temporary failure; try the operation again | ||
COUCHBASE_KEY_ENOENT | Requested document ID does not exist | ||
COUCHBASE_NOT_MY_VBUCKET | The command was sent to the wrong server; may be triggered during a rebalance or failover operation. Retry the operation | ||
COUCHBASE_NOT_STORED | The object was not stored | ||
docid | Document ID of deleted document | ||
| Arguments | |||
string key | Document ID used to identify the value | ||
Remove the item with a specified key
client.Remove("badkey");| API Call | object.ExecuteRemove(key) | ||
| Asynchronous | no | ||
| Description | Delete a key/value | ||
| Returns | IRemoveOperationResult (
Remove operation result
) | ||
| Arguments | |||
string key | Document ID used to identify the value | ||
ExecuteRemove removes an item by key and
returns an instance of an
IRemoveOperationResult
var result = client.ExecuteRemove("badkey"); if (! result.Succes) { Console.WriteLine("Remove failed with message {0} and status code {1}", result.Message, result.StatusCode); if (result.Exception != null) { throw result.Exception; } }
| API Call | object.ExecuteRemove-cas(key, casunique) | ||
| Asynchronous | no | ||
| Description | Delete a key/value | ||
| Returns | IRemoveOperationResult (
Remove operation result
) | ||
| Arguments | |||
string key | Document ID used to identify the value | ||
ulong casunique | Unique value used to verify a key/value combination | ||
ExecuteRemove removes an item by key using a
CAS operation and returns an instance of an
IRemoveOperationResult
var result = client.ExecuteRemove("badkey", 86753091234); if (! result.Succes) { Console.WriteLine("Remove failed with message {0} and status code {1}", result.Message, result.StatusCode); if (result.Exception != null) { throw result.Exception; } }
| API Call | object.ExecuteRemove(key) | ||
| Asynchronous | no | ||
| Description | Delete a key/value | ||
| Returns | IRemoveOperationResult (
Remove operation result
) | ||
| Arguments | |||
string key | Document ID used to identify the value | ||
The ExecuteRemove() method may define
persistence requirements. This operation will return success only
when the key has been removed from the specified number of nodes.
PersistTo.One will ensure removal from the
key's master node and not consider removal of its replicas. A
common use of this option is to combine it with a non-stale view
query, to guarantee that a deleted key is not returned in a view
result.
var result = client.ExecuteRemove("city_NC_Raleigh", PersistTo.One); if (! result.Succes) { Console.WriteLine("Remove failed with message {0} and status code {1}", result.Message, result.StatusCode); if (result.Exception != null) { throw result.Exception; } } else { var view = client.GetView("cities", "by_name").Stale(StaleMode.False); //safe to iterate this view, because the key has been removed from disk //and the index was updated. }