Couchbase C++ SDK 1.0.2 (rev. 51f4775)
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
69 template<typename Document,
70 typename Transcoder = codec::default_json_transcoder,
71 std::enable_if_t<!codec::is_transcoder_v<Document>, bool> = true,
72 std::enable_if_t<codec::is_transcoder_v<Transcoder>, bool> = true>
73 [[nodiscard]] auto content_as() const -> Document
74 {
75 return Transcoder::template decode<Document>(content());
76 }
77
83 template<typename Transcoder, std::enable_if_t<codec::is_transcoder_v<Transcoder>, bool> = true>
84 [[nodiscard]] auto content_as() const -> typename Transcoder::document_type
85 {
86 return Transcoder::decode(content());
87 }
88
94 [[nodiscard]] auto id() const -> const std::string&;
95
96private:
97 std::shared_ptr<couchbase::core::transactions::transaction_get_result> base_{};
98
100 std::shared_ptr<couchbase::core::transactions::transaction_get_result> base)
101 : base_(std::move(base))
102 {
103 }
104
105 [[nodiscard]] auto content() const -> const codec::encoded_value&;
106
109
110 [[nodiscard]] auto bucket() const -> const std::string&;
111 [[nodiscard]] auto scope() const -> const std::string&;
112 [[nodiscard]] auto collection() const -> const std::string&;
113 [[nodiscard]] auto cas() const -> couchbase::cas;
114};
115} // namespace couchbase::transactions
Provides access to Couchbase bucket.
Definition bucket.hxx:45
CAS is a special type that represented in protocol using unsigned 64-bit integer, but only equality c...
Definition cas.hxx:34
The collection provides access to all collection APIs.
Definition collection.hxx:70
The scope identifies a group of collections and allows high application density as a result.
Definition scope.hxx:47
The representation of the document in context of distributed transaction.
Definition transaction_get_result.hxx:57
auto content_as() const -> typename Transcoder::document_type
Content of the document.
Definition transaction_get_result.hxx:84
auto id() const -> const std::string &
Get document id.
friend class couchbase::core::transactions::attempt_context_impl
Definition transaction_get_result.hxx:108
friend class couchbase::core::transactions::transaction_get_result
Definition transaction_get_result.hxx:107
auto content_as() const -> Document
Content of the document.
Definition transaction_get_result.hxx:73
The transactions object is used to initiate a transaction.
Definition transactions.hxx:39
json_transcoder< tao_json_serializer > default_json_transcoder
Definition default_json_transcoder.hxx:28
Definition transaction_get_result.hxx:27
Definition transactions.hxx:28
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28