Couchbase C Client  3.3.10
Asynchronous C Client for Couchbase

Detailed Description

Remove documents.

Functions

lcb_STATUS lcb_respremove_status (const lcb_RESPREMOVE *resp)
 
lcb_STATUS lcb_respremove_error_context (const lcb_RESPREMOVE *resp, const lcb_KEY_VALUE_ERROR_CONTEXT **ctx)
 
lcb_STATUS lcb_respremove_cookie (const lcb_RESPREMOVE *resp, void **cookie)
 
lcb_STATUS lcb_respremove_cas (const lcb_RESPREMOVE *resp, uint64_t *cas)
 
lcb_STATUS lcb_respremove_key (const lcb_RESPREMOVE *resp, const char **key, size_t *key_len)
 
lcb_STATUS lcb_respremove_mutation_token (const lcb_RESPREMOVE *resp, lcb_MUTATION_TOKEN *token)
 
lcb_STATUS lcb_cmdremove_create (lcb_CMDREMOVE **cmd)
 
lcb_STATUS lcb_cmdremove_destroy (lcb_CMDREMOVE *cmd)
 
lcb_STATUS lcb_cmdremove_parent_span (lcb_CMDREMOVE *cmd, lcbtrace_SPAN *span)
 
lcb_STATUS lcb_cmdremove_collection (lcb_CMDREMOVE *cmd, const char *scope, size_t scope_len, const char *collection, size_t collection_len)
 
lcb_STATUS lcb_cmdremove_key (lcb_CMDREMOVE *cmd, const char *key, size_t key_len)
 
lcb_STATUS lcb_cmdremove_cas (lcb_CMDREMOVE *cmd, uint64_t cas)
 
lcb_STATUS lcb_cmdremove_durability (lcb_CMDREMOVE *cmd, lcb_DURABILITY_LEVEL level)
 
lcb_STATUS lcb_cmdremove_timeout (lcb_CMDREMOVE *cmd, uint32_t timeout)
 
lcb_STATUS lcb_cmdremove_on_behalf_of (lcb_CMDREMOVE *cmd, const char *data, size_t data_len)
 
lcb_STATUS lcb_cmdremove_on_behalf_of_extra_privilege (lcb_CMDREMOVE *cmd, const char *privilege, size_t privilege_len)
 
lcb_STATUS lcb_remove (lcb_INSTANCE *instance, void *cookie, const lcb_CMDREMOVE *cmd)
 

Typedefs

typedef struct lcb_RESPREMOVE_ lcb_RESPREMOVE
 Spool a removal of an item. More...
 
typedef struct lcb_CMDREMOVE_ lcb_CMDREMOVE
 

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.