Couchbase C Client  2.10.7
Asynchronous C Client for Couchbase

Detailed Description

Remove documents from the cluster.

Functions

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

Typedefs

typedef lcb_CMDBASE lcb_CMDREMOVE
 Command for removing an item from the server. More...
 
typedef lcb_RESPBASE lcb_RESPREMOVE
 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.

Stability
Committed:
Parameters
instancethe handle
cookiepointer to associate with the request
cmdthe command
Returns
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

◆ lcb_CMDREMOVE

Command for removing an item from the server.

Note
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

◆ lcb_RESPREMOVE

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.

lcb_strerror
const char * lcb_strerror(lcb_t instance, lcb_error_t error)
Get a textual descrtiption for the given error code.
LCB_CALLBACK_REMOVE
@ LCB_CALLBACK_REMOVE
lcb_remove3()
Definition: couchbase.h:701
lcb_remove3
lcb_error_t lcb_remove3(lcb_t instance, const void *cookie, const lcb_CMDREMOVE *cmd)
Spool a removal of an item.
lcb_RESPGET::nkey
lcb_SIZE nkey
Size of key.
Definition: couchbase.h:853
lcb_RESPGET::key
const void * key
Key for request.
Definition: couchbase.h:853
lcb_RESPBASE::rc
lcb_error_t rc
Status code.
Definition: couchbase.h:626
LCB_CMD_SET_KEY
#define LCB_CMD_SET_KEY(cmd, keybuf, keylen)
Set the key for the command.
Definition: couchbase.h:556
lcb_t
struct lcb_st * lcb_t
Definition: couchbase.h:41
LCB_SUCCESS
@ LCB_SUCCESS
Success.
Definition: error.h:478
lcb_RESPBASE
Base response structure for callbacks.
Definition: couchbase.h:625
lcb_CMDBASE
Common ABI header for all commands.
Definition: couchbase.h:522
lcb_install_callback3
lcb_RESPCALLBACK lcb_install_callback3(lcb_t instance, int cbtype, lcb_RESPCALLBACK cb)