Couchbase C Client  2.10.0
Asynchronous C Client for Couchbase

Detailed Description

Remove documents from the cluster.


lcb_error_t lcb_remove3 (lcb_t instance, const void *cookie, const lcb_CMDREMOVE *cmd)
 Spool a removal of an item. More...


typedef lcb_CMDBASE lcb_CMDREMOVE
 Command for removing an item from the server. More...
 Response structure for removal operation. More...

Function Documentation

◆ lcb_remove3()

lcb_error_t lcb_remove3 ( lcb_t  instance,
const void *  cookie,
const lcb_CMDREMOVE cmd 

Spool a removal of an item.

instancethe handle
cookiepointer to associate with the request
cmdthe command
LCB_SUCCESS on success, other code on failure

### Request

lcb_CMDREMOVE cmd = { 0 };
LCB_CMD_SET_KEY(&cmd, "deleteme", strlen("deleteme"));
lcb_remove3(instance, cookie, &cmd);

### Response

void rm_callback(lcb_t instance, int cbtype, const lcb_RESPBASE *rb)
printf("Key: %.*s...", (int)resp->nkey, resp->key);
if (rb->rc != LCB_SUCCESS) {
printf("Failed to remove item!: %s\n", lcb_strerror(NULL, rb->rc));
} else {
printf("Removed item!\n");

The following operation-specific error codes are returned in the callback

Typedef Documentation


Command for removing an item from the server.

The lcb_CMDREMOVE::exptime field here does nothing.

The lcb_CMDREMOVE::cas field may be set to the last CAS received from a previous operation if you wish to ensure the item is removed only if it has not been mutated since the last retrieval


Response structure for removal operation.

The lcb_RESPREMOVE::cas field may be used to check that it no longer exists on any node's storage using the lcb_endure3_ctxnew() function. You can also use the lcb_MUTATION_TOKEN (via lcb_resp_get_mutation_token)

The lcb_RESPREMOVE::rc field may be set to LCB_KEY_ENOENT if the item does not exist, or LCB_KEY_EEXISTS if a CAS was specified and the item has since been mutated.