33class tao_json_serializer;
75 , entries_{ std::move(entries) }
90 template<
typename Document,
92 std::enable_if_t<codec::is_serializer_v<Serializer>,
bool> =
true>
93 [[nodiscard]]
auto content_as(std::size_t index)
const -> Document
95 for (
const entry& e : entries_) {
96 if (e.original_index == index) {
98 throw std::system_error(e.ec,
99 "error getting result for spec at index " +
100 std::to_string(index) +
", path \"" + e.path +
"\"");
103 return Serializer::template deserialize<Document>(e.value);
107 "invalid index for lookup_in result: {}" + std::to_string(index));
120 template<
typename Document,
122 std::enable_if_t<codec::is_serializer_v<Serializer>,
bool> =
true>
123 [[nodiscard]]
auto content_as(
const std::string& path)
const -> Document
125 for (
const entry& e : entries_) {
126 if (e.path == path) {
128 throw std::system_error(e.ec,
"error getting result for path \"" + e.path +
"\"");
131 return Serializer::template deserialize<Document>(e.value);
135 "invalid path for lookup_in result: " + path);
148 template<
typename Document,
150 std::enable_if_t<codec::is_serializer_v<Serializer>,
bool> =
true>
154 for (
const entry& e : entries_) {
155 if (e.path == macro_string) {
157 throw std::system_error(e.ec,
"error getting result for macro \"" + macro_string +
"\"");
160 return Serializer::template deserialize<Document>(e.value);
164 "invalid path for lookup_in result: macro#" +
165 std::to_string(
static_cast<std::uint32_t
>(macro)));
177 [[nodiscard]]
auto exists(std::size_t index)
const ->
bool
179 for (
const entry& e : entries_) {
180 if (e.original_index == index) {
182 throw std::system_error(e.ec,
"error getting result for path \"" + e.path +
"\"");
203 for (
const entry& e : entries_) {
204 if (e.path == macro_string) {
206 throw std::system_error(e.ec,
"error getting result for macro \"" + macro_string +
"\"");
224 [[nodiscard]]
auto exists(
const std::string& path)
const ->
bool
226 for (
const entry& e : entries_) {
227 if (e.path == path) {
229 throw std::system_error(e.ec,
"error getting result for path \"" + e.path +
"\"");
264 [[nodiscard]]
auto has_value(std::size_t index)
const ->
bool
266 for (
const entry& e : entries_) {
267 if (e.original_index == index) {
268 return !e.value.empty();
272 "invalid index for mutate_in result: " + std::to_string(index));
284 [[nodiscard]]
auto has_value(
const std::string& path)
const ->
bool
286 for (
const entry& e : entries_) {
287 if (e.path == path) {
288 return !e.value.empty();
292 "invalid path for mutate_in result: " + path);
296 std::vector<entry> entries_{};
297 bool is_deleted_{
false };
CAS is a special type that represented in protocol using unsigned 64-bit integer, but only equality c...
Definition cas.hxx:34
Definition tao_json_serializer.hxx:42
Represents result of lookup_in operations.
Definition lookup_in_result.hxx:43
auto exists(subdoc::lookup_in_macro macro) const -> bool
Allows to check if a value at the given index exists.
Definition lookup_in_result.hxx:200
auto content_as(subdoc::lookup_in_macro macro) const -> Document
Decodes field of the document into type.
Definition lookup_in_result.hxx:151
lookup_in_result(couchbase::cas cas, std::vector< entry > entries, bool is_deleted)
Constructs result for lookup_in_result operation.
Definition lookup_in_result.hxx:73
auto exists(std::size_t index) const -> bool
Allows to check if a value at the given index exists.
Definition lookup_in_result.hxx:177
lookup_in_result()=default
auto content_as(const std::string &path) const -> Document
Decodes field of the document into type.
Definition lookup_in_result.hxx:123
auto has_value(const std::string &path) const -> bool
Returns whether the field has value.
Definition lookup_in_result.hxx:284
auto has_value(std::size_t index) const -> bool
Returns whether the field has value.
Definition lookup_in_result.hxx:264
auto is_deleted() const -> bool
Returns whether this document was deleted (a tombstone).
Definition lookup_in_result.hxx:250
auto content_as(std::size_t index) const -> Document
Decodes field of the document into type.
Definition lookup_in_result.hxx:93
auto exists(const std::string &path) const -> bool
Allows to check if a value at the given index exists.
Definition lookup_in_result.hxx:224
Base class for operations of data service.
Definition result.hxx:32
std::vector< std::byte > binary
Definition encoded_value.hxx:25
@ path_not_found
The path provided for a sub-document operation was not found.
@ path_invalid
The path provided for a sub-document operation was not syntactically correct.
lookup_in_macro
Definition lookup_in_macro.hxx:29
auto to_string(lookup_in_macro value) -> std::string
Converts macro into binary array suitable for sending to the server.
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28
Definition lookup_in_result.hxx:49
std::error_code ec
Definition lookup_in_result.hxx:54
std::string path
Definition lookup_in_result.hxx:50
codec::binary value
Definition lookup_in_result.hxx:51
std::size_t original_index
Definition lookup_in_result.hxx:52
bool exists
Definition lookup_in_result.hxx:53