Couchbase C++ SDK 1.4.0 (rev. 59aa900)
Loading...
Searching...
No Matches
transaction_get_result.hxx
Go to the documentation of this file.
1/*
2 * Copyright 2021-Present Couchbase, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
18#include <string>
19
20#include <couchbase/cas.hxx>
23#include <couchbase/result.hxx>
24
25// forward declarations...
27{
28class attempt_context_impl;
29class transaction_get_result;
30class transaction_links;
31class document_metadata;
32} // namespace couchbase::core::transactions
33
35{
57{
58public:
63
72 template<typename Document, std::enable_if_t<!codec::is_transcoder_v<Document>, bool> = true>
73 [[nodiscard]] auto content_as() const -> Document
74 {
76 }
77
83 template<typename Document,
84 typename Transcoder,
85 std::enable_if_t<!codec::is_transcoder_v<Document>, bool> = true,
86 std::enable_if_t<codec::is_transcoder_v<Transcoder>, bool> = true>
87 [[nodiscard]] auto content_as() const -> Document
88 {
89 return Transcoder::template decode<Document>(content());
90 }
91
97 template<typename Transcoder, std::enable_if_t<codec::is_transcoder_v<Transcoder>, bool> = true>
98 [[nodiscard]] auto content_as() const -> typename Transcoder::document_type
99 {
100 return Transcoder::decode(content());
101 }
102
108 [[nodiscard]] auto id() const -> const std::string&;
109
110private:
111 std::shared_ptr<couchbase::core::transactions::transaction_get_result> base_{};
112
113 explicit transaction_get_result(
114 std::shared_ptr<couchbase::core::transactions::transaction_get_result> base)
115 : base_(std::move(base))
116 {
117 }
118
119 [[nodiscard]] auto content() const -> const codec::encoded_value&;
120
123
124 [[nodiscard]] auto bucket() const -> const std::string&;
125 [[nodiscard]] auto scope() const -> const std::string&;
126 [[nodiscard]] auto collection() const -> const std::string&;
127 [[nodiscard]] auto cas() const -> couchbase::cas;
128};
129} // namespace couchbase::transactions
static auto decode(const encoded_value &encoded) -> Document
Definition lenient_json_transcoder.hxx:56
auto content_as() const -> typename Transcoder::document_type
Content of the document, decoded with the given transcoder.
Definition transaction_get_result.hxx:98
auto content_as() const -> Document
Content of the document.
Definition transaction_get_result.hxx:73
auto id() const -> const std::string &
Get document id.
friend class couchbase::core::transactions::attempt_context_impl
Definition transaction_get_result.hxx:122
friend class couchbase::core::transactions::transaction_get_result
Definition transaction_get_result.hxx:121
auto content_as() const -> Document
Content of the document, decoded with the given transcoder.
Definition transaction_get_result.hxx:87
The transactions object is used to initiate a transaction.
Definition transactions.hxx:52
Definition analytics_options.hxx:36
Definition transaction_get_multi_options.hxx:23
Definition expiry.hxx:24
Definition transactions.hxx:43
Represents a single item from the result of scan().
Definition allow_querying_search_index_options.hxx:28