Exposes collection-level kv operations.
More...
#include <collection.hxx>
|
result | get (const std::string &id, const get_options &opts=get_options()) |
| Get a document by key. More...
|
|
result | exists (const std::string &id, const exists_options &opts=exists_options()) |
| Test existence of a document. More...
|
|
template<typename Content > |
result | upsert (const std::string &id, const Content &value, const upsert_options &opts=upsert_options()) |
| Upsert document. More...
|
|
template<typename Content > |
result | insert (const std::string &id, const Content &value, const insert_options &opts=insert_options()) |
| Insert document. More...
|
|
template<typename Content > |
result | replace (const std::string &id, const Content &value, const replace_options &opts=replace_options()) |
| Replace document. More...
|
|
result | remove (const std::string &id, const remove_options &opts=remove_options()) |
| Remove document. More...
|
|
result | mutate_in (const std::string &id, std::vector< mutate_in_spec > specs, const mutate_in_options &opts=mutate_in_options()) |
| Mutate some elements of a document. More...
|
|
result | lookup_in (const std::string &id, std::vector< lookup_in_spec > specs, const lookup_in_options &opts=lookup_in_options()) |
| Lookup some elements of a document. More...
|
|
CB_NODISCARD const std::string & | name () const |
| Get name of collection. More...
|
|
CB_NODISCARD const std::string & | scope () const |
| Name of scope for this collection. More...
|
|
CB_NODISCARD const std::string & | bucket_name () const |
| Get name of bucket for this collection. More...
|
|
CB_NODISCARD std::shared_ptr< couchbase::bucket > | get_bucket () |
| Get bucket for this collection. More...
|
|
CB_NODISCARD std::chrono::microseconds | default_kv_timeout () const |
| Return default timeout for the kv operations. More...
|
|
|
class | bucket |
|
result | store_impl (collection *coll, store_operation op, const std::string &id, const std::string &payload, uint64_t cas, durability_level level, std::chrono::microseconds timeout) |
|
Exposes collection-level kv operations.
- Examples:
- examples/game_server.cxx.
◆ bucket_name()
CB_NODISCARD const std::string& couchbase::collection::bucket_name |
( |
| ) |
const |
|
inline |
Get name of bucket for this collection.
- Returns
- Name of bucket for this collection.
◆ default_kv_timeout()
CB_NODISCARD std::chrono::microseconds couchbase::collection::default_kv_timeout |
( |
| ) |
const |
|
inline |
◆ exists()
Test existence of a document.
- Parameters
-
id | Key of document. |
opts | Options for this command. |
- Returns
- result The result::value will be true if document exists, false otherwise.
◆ get()
Get a document by key.
Returns a result containing document if a document with that key exists, otherwise the result will contain the error.
- Parameters
-
id | Key of document to get. |
opts | Options to use for this command. |
- Returns
- result The result of the operation. See result.
- Examples:
- examples/game_server.cxx.
◆ get_bucket()
CB_NODISCARD std::shared_ptr<couchbase::bucket> couchbase::collection::get_bucket |
( |
| ) |
|
|
inline |
Get bucket for this collection.
- Returns
- bucket for this collection.
◆ insert()
template<typename Content >
Insert document.
Inserts a new document with the Content given.
- Parameters
-
id | Key of document to insert. |
value | The document itself. Note that the object either needs to be an nlohmann::json object or there needs to be to/from_json functions defined for it. |
opts | Options to use when inserting. For instance, you can set a durability. See insert_options. |
- Returns
- Result of the operation.
◆ lookup_in()
Lookup some elements of a document.
Lookup some elements in a document. See lookup_in_spec for the various possibilities and limitations. Useful when you don't want to fetch and parse entire document.
- Parameters
-
id | Key of doc to mutate. |
specs | Vector of specs that represent the mutations. |
opts | Options to use when mutating. You can specify a durability or cas, for instance. See mutate_in_options. |
- Returns
- Result of operation.
◆ mutate_in()
Mutate some elements of a document.
Mutates some paths within a document. See mutate_in_spec for the various possibilities and limitations. Useful avoiding constructing, sending entire document, if all you want to do is modify a small fraction of it.
- Parameters
-
id | Key of doc to mutate. |
specs | Vector of specs that represent the mutations. |
opts | Options to use when mutating. You can specify a durability or cas, for instance. See mutate_in_options. |
- Returns
- Result of operation.
◆ name()
CB_NODISCARD const std::string& couchbase::collection::name |
( |
| ) |
const |
|
inline |
Get name of collection.
- Returns
- Name of collection. Note the default collection is named "_default".
◆ remove()
Remove document.
Removes an existing document.
- Parameters
-
id | Key of document to remove. |
opts | Options to use when removing. For instance, you can set a durability or cas. See remove_options. |
- Returns
- Result of the operation.
◆ replace()
template<typename Content >
Replace document.
Replaces an existing document with the Content given.
- Parameters
-
id | Key of document to replace. |
value | The document itself. Note that the object either needs to be an nlohmann::json object or there needs to be to/from_json functions defined for it. |
opts | Options to use when replacing. For instance, you can set a durability or cas. See replace_options. |
- Returns
- Result of the operation.
◆ scope()
CB_NODISCARD const std::string& couchbase::collection::scope |
( |
| ) |
const |
|
inline |
Name of scope for this collection.
- Returns
- Scope of collection. Note default scope is "_default".
◆ upsert()
template<typename Content >
Upsert document.
Inserts a new document or replaces an existing document, with the Content given.
- Parameters
-
id | Key of document to upsert. |
value | The document itself. Note that the object either needs to be an nlohmann::json object or there needs to be to/from_json functions defined for it. |
opts | Options to use when upserting. For instance, you can set a durability. See upsert_options. |
- Returns
- Result of the operation.
- Examples:
- examples/game_server.cxx.
The documentation for this class was generated from the following file: