Couchbase C++ SDK 1.0.1 (rev. 58d46d7)
Loading...
Searching...
No Matches
mutate_in_specs Class Reference

#include <couchbase/mutate_in_specs.hxx>

Public Member Functions

 mutate_in_specs ()=default
 
template<typename... Operation>
 mutate_in_specs (Operation... args)
 
template<typename Operation >
void push_back (const Operation &operation)
 Add subdocument operation to list of specs.
 
template<typename Operation , typename... Rest>
void push_back (const Operation &operation, Rest... args)
 Add subdocument operations to list of specs.
 
auto specs () const -> const std::vector< core::impl::subdoc::command > &
 Returns internal representation of the specs.
 

Static Public Member Functions

template<typename Value >
static auto replace (std::string path, const Value &value) -> subdoc::replace
 Creates a spec with the intention of replacing an existing value in a JSON document.
 
static auto replace (std::string path, subdoc::mutate_in_macro value) -> subdoc::replace
 Creates a spec with the intention of replacing an existing value in a JSON document.
 
static auto replace_raw (std::string path, std::vector< std::byte > value, bool expand_macro=false) -> subdoc::replace
 Creates a spec with the intention of replacing an existing value in a JSON document.
 
template<typename Value >
static auto insert (std::string path, const Value &value) -> subdoc::insert
 Creates a command with the intention of inserting a new value in a JSON object.
 
static auto insert (std::string path, subdoc::mutate_in_macro value) -> subdoc::insert
 Creates a command with the intention of inserting a new value in a JSON object.
 
static auto insert_raw (std::string path, std::vector< std::byte > value, bool expand_macro=false) -> subdoc::insert
 Creates a command with the intention of inserting a new value in a JSON object.
 
static auto remove (std::string path) -> subdoc::remove
 Creates a command with the intention of removing an existing value in a JSON object.
 
template<typename Value >
static auto upsert (std::string path, const Value &value) -> subdoc::upsert
 Creates a command with the intention of upserting a value in a JSON object.
 
static auto upsert (std::string path, subdoc::mutate_in_macro value) -> subdoc::upsert
 Creates a command with the intention of upserting a value in a JSON object.
 
static auto upsert_raw (std::string path, std::vector< std::byte > value, bool expand_macro=false) -> subdoc::upsert
 Creates a command with the intention of upserting a value in a JSON object.
 
static auto increment (std::string path, std::int64_t delta) -> subdoc::counter
 Creates a command with the intent of incrementing a numerical field in a JSON object.
 
static auto decrement (std::string path, std::int64_t delta) -> subdoc::counter
 Creates a command with the intent of decrementing a numerical field in a JSON object.
 
template<typename... Values>
static auto array_append (std::string path, Values... values) -> subdoc::array_append
 Creates a command with the intention of appending a value to an existing JSON array.
 
static auto array_append_raw (std::string path, std::vector< std::byte > values) -> subdoc::array_append
 Creates a command with the intention of appending a value to an existing JSON array.
 
template<typename... Values>
static auto array_prepend (std::string path, Values... values) -> subdoc::array_prepend
 Creates a command with the intention of prepending a value to an existing JSON array.
 
static auto array_prepend_raw (std::string path, std::vector< std::byte > values) -> subdoc::array_prepend
 Creates a command with the intention of prepending a value to an existing JSON array.
 
template<typename... Values>
static auto array_insert (std::string path, Values... values) -> subdoc::array_insert
 Creates a command with the intention of inserting a value into an existing JSON array.
 
static auto array_insert_raw (std::string path, std::vector< std::byte > values) -> subdoc::array_insert
 Creates a command with the intention of inserting a value into an existing JSON array.
 
template<typename Value >
static auto array_add_unique (std::string path, const Value &value) -> subdoc::array_add_unique
 Creates a command with the intent of inserting a value into an existing JSON array, but only if the value is not already contained in the array (by way of string comparison).
 
static auto array_add_unique (std::string path, subdoc::mutate_in_macro value) -> subdoc::array_add_unique
 Creates a command with the intent of inserting a value into an existing JSON array, but only if the value is not already contained in the array (by way of string comparison).
 
static auto array_add_unique_raw (std::string path, std::vector< std::byte > value, bool expand_macro=false) -> subdoc::array_add_unique
 Creates a command with the intent of inserting a value into an existing JSON array, but only if the value is not already contained in the array (by way of string comparison).
 

Constructor & Destructor Documentation

◆ mutate_in_specs() [1/2]

mutate_in_specs ( )
default

◆ mutate_in_specs() [2/2]

template<typename... Operation>
mutate_in_specs ( Operation... args)
inlineexplicit

Member Function Documentation

◆ array_add_unique() [1/2]

template<typename Value >
static auto array_add_unique ( std::string path,
const Value & value ) -> subdoc::array_add_unique
inlinestatic

Creates a command with the intent of inserting a value into an existing JSON array, but only if the value is not already contained in the array (by way of string comparison).

Will error if the last element of the path does not exist or is not an array.

Parameters
paththe path identifying an array to which to append the value, and an index. E.g. "foo.bar[3]"
valuethe value to insert.
Returns
the created spec
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ array_add_unique() [2/2]

static auto array_add_unique ( std::string path,
subdoc::mutate_in_macro value ) -> subdoc::array_add_unique
inlinestatic

Creates a command with the intent of inserting a value into an existing JSON array, but only if the value is not already contained in the array (by way of string comparison).

Will error if the last element of the path does not exist or is not an array. The macro will be expanded on the server side.

Parameters
paththe path identifying an array to which to append the value, and an index. E.g. "foo.bar[3]"
valuethe macro value to insert.
Returns
the created spec
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ array_add_unique_raw()

static auto array_add_unique_raw ( std::string path,
std::vector< std::byte > value,
bool expand_macro = false ) -> subdoc::array_add_unique
inlinestatic

Creates a command with the intent of inserting a value into an existing JSON array, but only if the value is not already contained in the array (by way of string comparison).

Will error if the last element of the path does not exist or is not an array.

Note
this is low-level method that expect pre-formatted value.
Parameters
paththe path identifying an array to which to append the value, and an index. E.g. "foo.bar[3]"
valuethe value to insert.
expand_macrotrue if the value encodes macro
Returns
the created spec
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ array_append()

template<typename... Values>
static auto array_append ( std::string path,
Values... values ) -> subdoc::array_append
inlinestatic

Creates a command with the intention of appending a value to an existing JSON array.

Will error if the last element of the path does not exist or is not an array.

Parameters
paththe path identifying an array to which to append the value.
valuesthe value(s) to append.
Returns
the created spec
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ array_append_raw()

static auto array_append_raw ( std::string path,
std::vector< std::byte > values ) -> subdoc::array_append
inlinestatic

Creates a command with the intention of appending a value to an existing JSON array.

Will error if the last element of the path does not exist or is not an array.

Note
this is low-level method that expect pre-formatted value.
Parameters
paththe path identifying an array to which to append the value.
valuesthe value(s) to append.
Returns
the created spec
Since
1.0.0
Internal
Internal interface

◆ array_insert()

template<typename... Values>
static auto array_insert ( std::string path,
Values... values ) -> subdoc::array_insert
inlinestatic

Creates a command with the intention of inserting a value into an existing JSON array.

Will error if the last element of the path does not exist or is not an array.

Parameters
paththe path identifying an array to which to append the value, and an index. E.g. "foo.bar[3]"
valuesthe value(s) to insert.
Returns
the created spec
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ array_insert_raw()

static auto array_insert_raw ( std::string path,
std::vector< std::byte > values ) -> subdoc::array_insert
inlinestatic

Creates a command with the intention of inserting a value into an existing JSON array.

Will error if the last element of the path does not exist or is not an array.

Note
this is low-level method that expect pre-formatted value.
Parameters
paththe path identifying an array to which to append the value, and an index. E.g. "foo.bar[3]"
valuesthe value(s) to insert.
Returns
the created spec
Since
1.0.0
Internal
Internal interface

◆ array_prepend()

template<typename... Values>
static auto array_prepend ( std::string path,
Values... values ) -> subdoc::array_prepend
inlinestatic

Creates a command with the intention of prepending a value to an existing JSON array.

Will error if the last element of the path does not exist or is not an array.

Parameters
paththe path identifying an array to which to append the value.
valuesthe value(s) to prepend.
Returns
the created spec
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ array_prepend_raw()

static auto array_prepend_raw ( std::string path,
std::vector< std::byte > values ) -> subdoc::array_prepend
inlinestatic

Creates a command with the intention of prepending a value to an existing JSON array.

Will error if the last element of the path does not exist or is not an array.

Note
this is low-level method that expect pre-formatted value.
Parameters
paththe path identifying an array to which to append the value.
valuesthe value(s) to prepend.
Returns
the created spec
Since
1.0.0
Internal
Internal interface

◆ decrement()

static auto decrement ( std::string path,
std::int64_t delta ) -> subdoc::counter
inlinestatic

Creates a command with the intent of decrementing a numerical field in a JSON object.

Parameters
paththe path identifying a numerical field to adjust or create.
deltathe positive value to decrement the field by.
Returns
the created spec
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ increment()

static auto increment ( std::string path,
std::int64_t delta ) -> subdoc::counter
inlinestatic

Creates a command with the intent of incrementing a numerical field in a JSON object.

If the field does not exist then it is created and takes the value of delta.

Parameters
paththe path identifying a numerical field to adjust or create.
deltathe positive value to increment the field by.
Returns
the created spec
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ insert() [1/2]

template<typename Value >
static auto insert ( std::string path,
const Value & value ) -> subdoc::insert
inlinestatic

Creates a command with the intention of inserting a new value in a JSON object.

Will error if the last element of the path already exists.

Parameters
paththe path identifying where to insert the value.
valuethe value to insert
Returns
the created spec
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ insert() [2/2]

static auto insert ( std::string path,
subdoc::mutate_in_macro value ) -> subdoc::insert
inlinestatic

Creates a command with the intention of inserting a new value in a JSON object.

The macro will be expanded on the server side. Will error if the last element of the path already exists.

Parameters
paththe path identifying where to insert the value.
valuethe value to insert
Returns
the created spec
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ insert_raw()

static auto insert_raw ( std::string path,
std::vector< std::byte > value,
bool expand_macro = false ) -> subdoc::insert
inlinestatic

Creates a command with the intention of inserting a new value in a JSON object.

Will error if the last element of the path already exists.

Note
this is low-level method that expect pre-formatted value.
Parameters
paththe path identifying where to insert the value.
valuethe value to insert
expand_macrotrue if the value encodes macro
Returns
the created spec
Since
1.0.0
Internal
Internal interface

◆ push_back() [1/2]

template<typename Operation >
void push_back ( const Operation & operation)
inline

Add subdocument operation to list of specs.

Template Parameters
Operationtype of the subdocument operation
Parameters
operationoperation to execute
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ push_back() [2/2]

template<typename Operation , typename... Rest>
void push_back ( const Operation & operation,
Rest... args )
inline

Add subdocument operations to list of specs.

Template Parameters
Operationtype of the subdocument operation
Resttypes of the rest of the operations
Parameters
operationoperation to execute
argsthe rest of the arguments
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ remove()

static auto remove ( std::string path) -> subdoc::remove
inlinestatic

Creates a command with the intention of removing an existing value in a JSON object.

Will error if the path does not exist.

Parameters
paththe path identifying what to remove.
Returns
the created spec
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ replace() [1/2]

template<typename Value >
static auto replace ( std::string path,
const Value & value ) -> subdoc::replace
inlinestatic

Creates a spec with the intention of replacing an existing value in a JSON document.

If the path is empty (""), then the value will be used for the document's full body. Will error if the last element of the path does not exist.

Parameters
paththe path identifying where to replace the value.
valuethe value to replace with.
Returns
the created spec
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ replace() [2/2]

static auto replace ( std::string path,
subdoc::mutate_in_macro value ) -> subdoc::replace
inlinestatic

Creates a spec with the intention of replacing an existing value in a JSON document.

The macro will be expanded on the server side.

Parameters
paththe path identifying where to replace the value.
valuethe value to replace with.
Returns
the created spec
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ replace_raw()

static auto replace_raw ( std::string path,
std::vector< std::byte > value,
bool expand_macro = false ) -> subdoc::replace
inlinestatic

Creates a spec with the intention of replacing an existing value in a JSON document.

If the path is empty (""), then the value will be used for the document's full body. Will error if the last element of the path does not exist.

Note
this is low-level method that expect pre-formatted value.
Parameters
paththe path identifying where to insert the value.
valuethe value to insert
expand_macrotrue if the value encodes macro
Returns
the created spec
Since
1.0.0
Internal
Internal interface

◆ specs()

auto specs ( ) const -> const std::vector< core::impl::subdoc::command > &

Returns internal representation of the specs.

Returns
specs
Since
1.0.0
Internal
Internal interface

◆ upsert() [1/2]

template<typename Value >
static auto upsert ( std::string path,
const Value & value ) -> subdoc::upsert
inlinestatic

Creates a command with the intention of upserting a value in a JSON object.

That is, the value will be replaced if the path already exists, or inserted if not.

Parameters
paththe path identifying where to upsert the value.
valuethe value to upsert.
Returns
the created spec
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ upsert() [2/2]

static auto upsert ( std::string path,
subdoc::mutate_in_macro value ) -> subdoc::upsert
inlinestatic

Creates a command with the intention of upserting a value in a JSON object.

That is, the value will be replaced if the path already exists, or inserted if not. The macro will be expanded on the server side.

Parameters
paththe path identifying where to upsert the value.
valuethe macro value to upsert.
Returns
the created spec
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ upsert_raw()

static auto upsert_raw ( std::string path,
std::vector< std::byte > value,
bool expand_macro = false ) -> subdoc::upsert
inlinestatic

Creates a command with the intention of upserting a value in a JSON object.

That is, the value will be replaced if the path already exists, or inserted if not.

Note
this is low-level method that expect pre-formatted value.
Parameters
paththe path identifying where to upsert the value.
valuethe value to upsert.
expand_macrotrue if the value encodes macro
Returns
the created spec
Since
1.0.0
Internal
Internal interface

The documentation for this class was generated from the following file: