MongoDB C++ Driver 4.4.0
Loading...
Searching...
No Matches
delete.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <mongocxx/options/delete-fwd.hpp> // IWYU pragma: export
18
19//
20
23
24#include <mongocxx/v1/delete_many_options.hpp> // IWYU pragma: export
25#include <mongocxx/v1/delete_one_options.hpp> // IWYU pragma: export
26
27#include <utility>
28
34
35#include <mongocxx/hint.hpp>
38
40
41namespace mongocxx {
42namespace v_noabi {
43namespace options {
44
49 public:
53 delete_options() = default;
54
59
64
68 explicit operator v1::delete_many_options() const {
71
73
74 if (_collation) {
75 ret.collation(bsoncxx::v1::document::value{to_v1(_collation->view())});
76 }
77
78 if (_read_concern) {
79 ret.read_concern(to_v1(*_read_concern));
80 }
81
82 if (_write_concern) {
83 ret.write_concern(to_v1(*_write_concern));
84 }
85
86 if (_hint) {
87 ret.hint(to_v1(*_hint));
88 }
89
90 if (_let) {
91 ret.let(bsoncxx::v1::document::value{to_v1(_let->view())});
92 }
93
94 if (_comment) {
95 ret.comment(bsoncxx::v1::types::value{to_v1(_comment->view())});
96 }
97
98 return ret;
99 }
100
104 explicit operator v1::delete_one_options() const {
107
109
110 if (_collation) {
111 ret.collation(bsoncxx::v1::document::value{to_v1(_collation->view())});
112 }
113
114 if (_read_concern) {
115 ret.read_concern(to_v1(*_read_concern));
116 }
117
118 if (_write_concern) {
119 ret.write_concern(to_v1(*_write_concern));
120 }
121
122 if (_hint) {
123 ret.hint(to_v1(*_hint));
124 }
125
126 if (_let) {
127 ret.let(bsoncxx::v1::document::value{to_v1(_let->view())});
128 }
129
130 if (_comment) {
131 ret.comment(bsoncxx::v1::types::value{to_v1(_comment->view())});
132 }
133
134 return ret;
135 }
136
151 _collation = std::move(collation);
152 return *this;
153 }
154
167
182 _read_concern = std::move(rc);
183 return *this;
184 }
185
196 return _read_concern;
197 }
198
213 _write_concern = std::move(wc);
214 return *this;
215 }
216
227 return _write_concern;
228 }
229
244 _hint = std::move(index_hint);
245 return *this;
246 }
247
254 return _hint;
255 }
256
268 _let = std::move(let);
269 return *this;
270 }
271
281
293 _comment = std::move(comment);
294 return *this;
295 }
296
306
307 private:
314};
315
316} // namespace options
317} // namespace v_noabi
318} // namespace mongocxx
319
320namespace mongocxx {
321namespace v_noabi {
322
327 return {std::move(v)};
328}
329
334 return {std::move(v)};
335}
336
337// Ambiguous whether `v_noabi::options::delete_options` should be converted to `v1::delete_many_options` or
338// `v1::delete_one_options`. Require users to explicitly cast to the expected type instead.
339//
340// v1::delete_many_options to_v1(v_noabi::options::delete_options const& v);
341// v1::delete_one_options to_v1(v_noabi::options::delete_options const& v);
342
343} // namespace v_noabi
344} // namespace mongocxx
345
347
A BSON document.
Definition value.hpp:44
A polyfill for std::optional<T>.
Definition optional.hpp:799
A union of BSON type values.
Definition value.hpp:52
delete_options()=default
Default initialization.
Options for a "deleteMany" operation.
Definition delete_many_options.hpp:53
delete_many_options & read_concern(v1::read_concern v)
Set the "readConcern" field.
delete_many_options & hint(v1::hint v)
Set the "hint" field.
delete_many_options & comment(bsoncxx::v1::types::value v)
Set the "comment" field.
delete_many_options & write_concern(v1::write_concern v)
Set the "writeConcern" field.
delete_many_options & collation(bsoncxx::v1::document::value v)
Set the "collation" field.
delete_many_options & let(bsoncxx::v1::document::value v)
Set the "let" field.
Options for a "deleteOne" operation.
Definition delete_one_options.hpp:53
delete_one_options & comment(bsoncxx::v1::types::value v)
Set the "comment" field.
delete_one_options & let(bsoncxx::v1::document::value v)
Set the "let" field.
delete_one_options & hint(v1::hint v)
Set the "hint" field.
delete_one_options & write_concern(v1::write_concern v)
Set the "writeConcern" field.
delete_one_options & read_concern(v1::read_concern v)
Set the "readConcern" field.
delete_one_options & collation(bsoncxx::v1::document::value v)
Set the "collation" field.
The index to "hint" or force a MongoDB server to use when performing a query.
Definition hint.hpp:42
Used by MongoDB delete operations.
Definition delete.hpp:48
delete_options & collation(bsoncxx::v_noabi::document::view_or_value collation)
Sets the collation for this operation.
Definition delete.hpp:150
delete_options()=default
Default initialization.
delete_options & let(bsoncxx::v_noabi::document::view_or_value let)
Set the value of the let option.
Definition delete.hpp:267
delete_options & hint(v_noabi::hint index_hint)
Sets the index to use for this operation.
Definition delete.hpp:243
bsoncxx::v_noabi::stdx::optional< v_noabi::hint > const & hint() const
Gets the current hint.
Definition delete.hpp:253
bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const & write_concern() const
The current write_concern for this operation.
Definition delete.hpp:226
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::types::bson_value::view_or_value > const comment() const
Gets the current value of the comment option.
Definition delete.hpp:303
delete_options & comment(bsoncxx::v_noabi::types::bson_value::view_or_value comment)
Set the value of the comment option.
Definition delete.hpp:292
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & collation() const
Retrieves the current collation for this operation.
Definition delete.hpp:164
operator v1::delete_one_options() const
Convert to the mongocxx::v1 equivalent.
Definition delete.hpp:104
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const let() const
Gets the current value of the let option.
Definition delete.hpp:278
operator v1::delete_many_options() const
Convert to the mongocxx::v1 equivalent.
Definition delete.hpp:68
delete_options & write_concern(v_noabi::write_concern wc)
Sets the write_concern for this operation.
Definition delete.hpp:212
bsoncxx::v_noabi::stdx::optional< v_noabi::read_concern > const & read_concern() const
The current read_concern for this operation.
Definition delete.hpp:195
delete_options & read_concern(v_noabi::read_concern rc)
Sets the read_concern for this operation.
Definition delete.hpp:181
Controls the consistency and isolation properties of data read from replica sets and sharded clusters...
Definition read_concern.hpp:54
The level of acknowledgment requested for write operations to a MongoDB server.
Definition write_concern.hpp:54
Provides mongocxx::v1::delete_many_options.
Provides mongocxx::v1::delete_one_options.
Provides bsoncxx::v_noabi::document::view_or_value.
#define MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to MONGOCXX_ABI_EXPORT_UNSTABLE with MONGOCXX_ABI_CDECL.
Definition config.hpp:28
The mongocxx v_noabi macro guard postlude header.
The mongocxx v_noabi macro guard prelude header.
v_noabi::view_or_value< v_noabi::document::view, v_noabi::document::value > view_or_value
Equivalent to v_noabi::view_or_value<v_noabi::document::view, v_noabi::document::value>.
Definition view_or_value.hpp:30
v_noabi::view_or_value< view, value > view_or_value
Equivalent to v_noabi::view_or_value<view, value>.
Definition view_or_value.hpp:31
v1::element::view to_v1(v_noabi::array::element const &v)
Convert to the bsoncxx::v1 equivalent of v.
Definition element.hpp:132
Declares entities whose ABI stability is guaranteed for documented symbols.
Declares entities representing options to use with various commands.
Declares entities whose ABI stability is NOT guaranteed.
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
The top-level namespace within which all mongocxx library entities are declared.
Declares mongocxx::v_noabi::options::delete_options.
Provides bsoncxx::v_noabi::types::bson_value::view_or_value.
Provides bsoncxx::v1::document::value.
Provides bsoncxx::v1::types::value.
Provides bsoncxx::v_noabi::document::view.
Provides std::optional-related polyfills for library API usage.
Provides bsoncxx::v_noabi::types::bson_value::view.
Provides mongocxx::v_noabi::hint.
Provides mongocxx::v_noabi::read_concern.
Provides mongocxx::v_noabi::write_concern.