Couchbase C Client  3.3.7
Asynchronous C Client for Couchbase
Remove

Detailed Description

Remove documents.

Function Documentation

โ—† lcb_cmdremove_on_behalf_of()

lcb_STATUS lcb_cmdremove_on_behalf_of ( lcb_CMDREMOVE *  cmd,
const char *  data,
size_t  data_len 
)
Stability
Internal:
Internal: This should never be used and is not supported.

โ—† lcb_cmdremove_on_behalf_of_extra_privilege()

lcb_STATUS lcb_cmdremove_on_behalf_of_extra_privilege ( lcb_CMDREMOVE *  cmd,
const char *  privilege,
size_t  privilege_len 
)
Stability
Internal:
Internal: This should never be used and is not supported.

Typedef Documentation

โ—† lcb_RESPREMOVE

typedef struct lcb_RESPREMOVE_ lcb_RESPREMOVE

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;
lcb_cmdremove_create(&cmd);
lcb_cmdremove_key(cmd, "deleteme", strlen("deleteme"));
lcb_remove(instance, cookie, &cmd);

Response

lcb_install_callback(instance, LCB_CALLBACK_REMOVE, rm_callback);
void rm_callback(lcb_INSTANCE *instance, int cbtype, const lcb_RESPBASE *rb)
{
const lcb_RESPREMOVE* resp = (const lcb_RESPREMOVE*)rb;
char* key;
size_t key_len;
lcb_STATUS rc = lcb_respremove_status(resp);
lcb_respremove_key(resp, &key, &key_len);
printf("Key: %.*s...", key_len, key);
if (rc != LCB_SUCCESS) {
printf("Failed to remove item!: %s\n", lcb_strerror_short(rc));
} else {
printf("Removed item!\n");
}
}
LCB_INTERNAL_API const char * lcb_strerror_short(lcb_STATUS error)
Get a shorter textual description of an error message.
lcb_STATUS
Error codes returned by the library.
Definition error.h:212
struct lcb_st lcb_INSTANCE
Library handle representing a connection to a cluster and its data buckets.
Definition couchbase.h:35
lcb_RESPCALLBACK lcb_install_callback(lcb_INSTANCE *instance, int cbtype, lcb_RESPCALLBACK cb)
@ LCB_CALLBACK_REMOVE
lcb_remove()
Definition couchbase.h:475
struct lcb_RESPREMOVE_ lcb_RESPREMOVE
Spool a removal of an item.
Definition couchbase.h:1101

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

  • ::LCB_ERR_DOCUMENT_NOT_FOUND if the key does not exist
  • ::LCB_ERR_DOCUMENT_EXISTS if the CAS was specified and it does not match the CAS on the server
  • ::LCB_ERR_DOCUMENT_EXISTS if the item was locked and no CAS (or an incorrect CAS) was specified.