MongoDB C++ Driver 4.2.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>
37
39
40namespace mongocxx {
41namespace v_noabi {
42namespace options {
43
48 public:
52 delete_options() = default;
53
58
63
67 explicit operator v1::delete_many_options() const {
70
72
73 if (_collation) {
74 ret.collation(bsoncxx::v1::document::value{to_v1(_collation->view())});
75 }
76
77 if (_write_concern) {
78 ret.write_concern(to_v1(*_write_concern));
79 }
80
81 if (_hint) {
82 ret.hint(to_v1(*_hint));
83 }
84
85 if (_let) {
86 ret.let(bsoncxx::v1::document::value{to_v1(_let->view())});
87 }
88
89 if (_comment) {
90 ret.comment(bsoncxx::v1::types::value{to_v1(_comment->view())});
91 }
92
93 return ret;
94 }
95
99 explicit operator v1::delete_one_options() const {
102
104
105 if (_collation) {
106 ret.collation(bsoncxx::v1::document::value{to_v1(_collation->view())});
107 }
108
109 if (_write_concern) {
110 ret.write_concern(to_v1(*_write_concern));
111 }
112
113 if (_hint) {
114 ret.hint(to_v1(*_hint));
115 }
116
117 if (_let) {
118 ret.let(bsoncxx::v1::document::value{to_v1(_let->view())});
119 }
120
121 if (_comment) {
122 ret.comment(bsoncxx::v1::types::value{to_v1(_comment->view())});
123 }
124
125 return ret;
126 }
127
142 _collation = std::move(collation);
143 return *this;
144 }
145
158
173 _write_concern = std::move(wc);
174 return *this;
175 }
176
187 return _write_concern;
188 }
189
204 _hint = std::move(index_hint);
205 return *this;
206 }
207
214 return _hint;
215 }
216
228 _let = std::move(let);
229 return *this;
230 }
231
241
253 _comment = std::move(comment);
254 return *this;
255 }
256
266
267 private:
273};
274
275} // namespace options
276} // namespace v_noabi
277} // namespace mongocxx
278
279namespace mongocxx {
280namespace v_noabi {
281
286 return {std::move(v)};
287}
288
293 return {std::move(v)};
294}
295
296// Ambiguous whether `v_noabi::options::delete_options` should be converted to `v1::delete_many_options` or
297// `v1::delete_one_options`. Require users to explicitly cast to the expected type instead.
298//
299// v1::delete_many_options to_v1(v_noabi::options::delete_options const& v);
300// v1::delete_one_options to_v1(v_noabi::options::delete_options const& v);
301
302} // namespace v_noabi
303} // namespace mongocxx
304
306
A BSON document.
Definition value.hpp:46
A polyfill for std::optional<T>.
Definition optional.hpp:799
A union of BSON type values.
Definition value.hpp:54
delete_options()=default
Default initialization.
Options for a "deleteMany" operation.
Definition delete_many_options.hpp:53
delete_many_options & let(bsoncxx::v1::document::value let)
Set the "let" field.
delete_many_options & collation(bsoncxx::v1::document::value collation)
Set the "collation" field.
delete_many_options & comment(bsoncxx::v1::types::value comment)
Set the "comment" field.
delete_many_options & hint(v1::hint index_hint)
Set the "hint" field.
delete_many_options & write_concern(write_concern wc)
Set the "writeConcern" field.
Options for a "deleteOne" operation.
Definition delete_one_options.hpp:53
delete_one_options & write_concern(v1::write_concern wc)
Set the "writeConcern" field.
delete_one_options & let(bsoncxx::v1::document::value let)
Set the "let" field.
delete_one_options & comment(bsoncxx::v1::types::value comment)
Set the "comment" field.
delete_one_options & hint(v1::hint index_hint)
Set the "hint" field.
delete_one_options & collation(bsoncxx::v1::document::value collation)
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:47
delete_options & collation(bsoncxx::v_noabi::document::view_or_value collation)
Sets the collation for this operation.
Definition delete.hpp:141
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:227
delete_options & hint(v_noabi::hint index_hint)
Sets the index to use for this operation.
Definition delete.hpp:203
bsoncxx::v_noabi::stdx::optional< v_noabi::hint > const & hint() const
Gets the current hint.
Definition delete.hpp:213
bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const & write_concern() const
The current write_concern for this operation.
Definition delete.hpp:186
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:263
delete_options & comment(bsoncxx::v_noabi::types::bson_value::view_or_value comment)
Set the value of the comment option.
Definition delete.hpp:252
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:155
operator v1::delete_one_options() const
Convert to the mongocxx::v1 equivalent.
Definition delete.hpp:99
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:238
operator v1::delete_many_options() const
Convert to the mongocxx::v1 equivalent.
Definition delete.hpp:67
delete_options & write_concern(write_concern wc)
Sets the write_concern for this operation.
Definition delete.hpp:172
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(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
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::write_concern.