Couchbase C++ SDK 1.0.2 (rev. 51f4775)
|
The async_attempt_context is used for all asynchronous transaction operations. More...
#include <couchbase/transactions/async_attempt_context.hxx>
Public Member Functions | |
virtual void | get (const collection &coll, std::string id, async_result_handler &&handler)=0 |
Get document from a collection. | |
virtual void | get_replica_from_preferred_server_group (const couchbase::collection &coll, const std::string &id, async_result_handler &&handler)=0 |
Get a document copy from the selected server group. | |
virtual void | remove (transaction_get_result doc, async_err_handler &&handler)=0 |
Remove a document from a collection. | |
template<typename Transcoder = codec::default_json_transcoder, typename Document , std::enable_if_t<!std::is_same_v< codec::encoded_value, Document >, bool > = true> | |
void | insert (const collection &coll, std::string id, Document &&content, async_result_handler &&handler) |
Insert a document into a collection. | |
template<typename Transcoder = codec::default_json_transcoder, typename Document , std::enable_if_t<!std::is_same_v< codec::encoded_value, Document >, bool > = true> | |
void | replace (transaction_get_result doc, Document &&content, async_result_handler &&handler) |
Replace the contents of a document in a collection. | |
void | query (const scope &scope, std::string statement, transaction_query_options opts, async_query_handler &&handler) |
Perform a query, within a scope. | |
void | query (std::string statement, transaction_query_options opts, async_query_handler &&handler) |
Perform a query. | |
void | query (std::string statement, async_query_handler &&handler) |
Perform a query. | |
virtual | ~async_attempt_context ()=default |
The async_attempt_context is used for all asynchronous transaction operations.
In the example below, we get 3 documents in parallel, and update each when the get returns the document:
|
virtualdefault |
|
pure virtual |
Get document from a collection.
Fetch the document contents, in the form of a transaction_get_result. This can be used in subsequent calls to async_attempt_context::replace or async_attempt_context::remove
coll | The collection which contains the document. |
id | The document id which is used to uniquely identify it. |
handler | The handler which implements async_result_handler |
|
pure virtual |
Get a document copy from the selected server group.
Fetch the document contents, in the form of a transaction_get_result. It might be either replica or active copy of the document. One of the use cases for this method is to save on network costs by deploying SDK in the same availability zone as corresponding server group of the nodes.
coll | The collection which contains the document. |
id | The unique id of the document. |
handler | The handler which implements async_result_handler |
Select preferred server group in connection options:
Fetch document from the nodes that belong to selected server group only:
|
inline |
Insert a document into a collection.
Given an id and the content, this inserts a new document into a collection. Note that currently this content can be either a <std::vector<std::byte>> or an object which can be serialized with the codec::tao_json_serializer.
Content | type of the document. |
coll | Collection to insert the document into. |
id | The document id. |
content | The content of the document. |
handler | The handler which implements async_result_handler |
void query | ( | const scope & | scope, |
std::string | statement, | ||
transaction_query_options | opts, | ||
async_query_handler && | handler ) |
Perform a query, within a scope.
Performs a query given a specific scope. Note that all subsequent transaction operations will be handled by the query service.
scope | Scope for the query. |
statement | The query statement |
opts | Options for the query |
handler | Handler which implements async_query_handler. |
|
inline |
Perform a query.
Performs an unscoped query.
statement | The query statement. |
handler | Handler which implements async_query_handler |
|
inline |
Perform a query.
Performs an unscoped query.
statement | The query statement. |
opts | Options for the query. |
handler | Handler which implements async_query_handler. |
|
pure virtual |
Remove a document from a collection.
Removes a document from a collection, where the document was gotten from a previous call to async_attempt_context::get
doc | The document to remove. |
handler | The handler which implements async_err_handler |
|
inline |
Replace the contents of a document in a collection.
Replaces the contents of an existing document. Note that currently this content can be either a <std::vector<std::byte>> or an object which can be serialized with the codec::tao_json_serializer.
Content | type of the document |
doc | Document whose content will be replaced. This is gotten from a call to async_attempt_context::get |
content | New content of the document |
handler | The handler which implements async_result_handler |