Couchbase C++ SDK 1.0.1 (rev. 58d46d7)
Loading...
Searching...
No Matches
mutate_in_options.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright 2020-Present Couchbase, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
21
24#include <couchbase/error.hxx>
25#include <couchbase/expiry.hxx>
28
29#include <chrono>
30#include <functional>
31#include <memory>
32#include <optional>
33#include <vector>
34
35namespace couchbase
36{
37
44struct mutate_in_options : public common_durability_options<mutate_in_options> {
51 struct built : public common_durability_options<mutate_in_options>::built {
52 const std::uint32_t expiry;
53 const bool preserve_expiry;
56 const bool access_deleted;
58 };
59
71 [[nodiscard]] auto build() const -> built
72 {
74 return { base, expiry_, preserve_expiry_, store_semantics_,
75 cas_, access_deleted_, create_as_deleted_ };
76 }
77
94 auto preserve_expiry(bool preserve) -> mutate_in_options&
95 {
96 preserve_expiry_ = preserve;
97 return self();
98 }
99
113 auto expiry(std::chrono::seconds duration) -> mutate_in_options&
114 {
115 expiry_ = core::impl::expiry_relative(duration);
116 return self();
117 }
118
129 auto expiry(std::chrono::system_clock::time_point time_point) -> mutate_in_options&
130 {
131 expiry_ = core::impl::expiry_absolute(time_point);
132 return self();
133 }
134
156 {
157 cas_ = cas;
158 return self();
159 }
175 {
176 store_semantics_ = semantics;
177 return self();
178 }
179
187 {
188 access_deleted_ = value;
189 return self();
190 }
191
199 {
200 create_as_deleted_ = value;
201 return self();
202 }
203
204private:
206 couchbase::cas cas_{};
207 std::uint32_t expiry_{ 0 };
208 bool preserve_expiry_{ false };
209 bool access_deleted_{ false };
210 bool create_as_deleted_{ false };
211};
212
219using mutate_in_handler = std::function<void(error, mutate_in_result)>;
220} // namespace couchbase
CAS is a special type that represented in protocol using unsigned 64-bit integer, but only equality c...
Definition cas.hxx:34
Common options that used by most operations.
Definition common_durability_options.hxx:39
auto build_common_durability_options() const -> built
Definition common_durability_options.hxx:100
auto self() -> derived_class &
Allows to return the right options builder instance for child implementations.
Definition common_options.hxx:102
Definition error.hxx:30
Represents result of mutate_in operations.
Definition mutate_in_result.hxx:35
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28
store_semantics
Describes how the outer document store semantics on subdoc should act.
Definition store_semantics.hxx:30
@ replace
Replace the document, fail if it does not exist.
std::function< void(error, mutate_in_result)> mutate_in_handler
The signature for the handler of the collection::mutate_in() operation.
Definition mutate_in_options.hxx:219
Immutable value object representing consistent options.
Definition mutate_in_options.hxx:51
const bool access_deleted
Definition mutate_in_options.hxx:56
const couchbase::cas cas
Definition mutate_in_options.hxx:55
const bool preserve_expiry
Definition mutate_in_options.hxx:53
const bool create_as_deleted
Definition mutate_in_options.hxx:57
const std::uint32_t expiry
Definition mutate_in_options.hxx:52
const couchbase::store_semantics store_semantics
Definition mutate_in_options.hxx:54
Options for collection::mutate_in().
Definition mutate_in_options.hxx:44
auto access_deleted(bool value) -> mutate_in_options &
For internal use only: allows access to deleted documents that are in 'tombstone' form.
Definition mutate_in_options.hxx:186
auto expiry(std::chrono::system_clock::time_point time_point) -> mutate_in_options &
Sets the expiry for the document.
Definition mutate_in_options.hxx:129
auto store_semantics(couchbase::store_semantics semantics) -> mutate_in_options &
Changes the storing semantics of the outer/enclosing document.
Definition mutate_in_options.hxx:174
auto create_as_deleted(bool value) -> mutate_in_options &
For internal use only: allows creating documents in 'tombstone' form.
Definition mutate_in_options.hxx:198
auto build() const -> built
Validates options and returns them as an immutable value.
Definition mutate_in_options.hxx:71
auto expiry(std::chrono::seconds duration) -> mutate_in_options &
Sets the expiry for the document.
Definition mutate_in_options.hxx:113
auto cas(couchbase::cas cas) -> mutate_in_options &
Specifies a CAS value that will be taken into account on the server side for optimistic concurrency.
Definition mutate_in_options.hxx:155
auto preserve_expiry(bool preserve) -> mutate_in_options &
Specifies whether an existing document's expiry should be preserved.
Definition mutate_in_options.hxx:94