MongoDB C++ Driver 4.4.0
Loading...
Searching...
No Matches
find_one_and_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/find_one_and_delete-fwd.hpp> // IWYU pragma: export
18
19//
20
23
24#include <mongocxx/v1/find_one_and_delete_options.hpp> // IWYU pragma: export
25
26#include <chrono>
27#include <cstdint> // IWYU pragma: keep: backward compatibility, to be removed.
28#include <utility>
29
35
36#include <mongocxx/hint.hpp>
39
41
42namespace mongocxx {
43namespace v_noabi {
44namespace options {
45
50 public:
55
61
65 explicit operator v1::find_one_and_delete_options() const {
68
70
71 if (_collation) {
72 ret.collation(bsoncxx::v1::document::value{to_v1(_collation->view())});
73 }
74
75 if (_max_time) {
76 ret.max_time(*_max_time);
77 }
78
79 if (_projection) {
80 ret.projection(bsoncxx::v1::document::value{to_v1(_projection->view())});
81 }
82
83 if (_ordering) {
84 ret.sort(bsoncxx::v1::document::value{to_v1(_ordering->view())});
85 }
86
87 if (_read_concern) {
88 ret.read_concern(to_v1(*_read_concern));
89 }
90
91 if (_write_concern) {
92 ret.write_concern(to_v1(*_write_concern));
93 }
94
95 if (_hint) {
96 ret.hint(to_v1(*_hint));
97 }
98
99 if (_let) {
100 ret.let(bsoncxx::v1::document::value{to_v1(_let->view())});
101 }
102
103 if (_comment) {
104 ret.comment(bsoncxx::v1::types::value{to_v1(_comment->view())});
105 }
106
107 return ret;
108 }
109
123 _collation = std::move(collation);
124 return *this;
125 }
126
139
153 find_one_and_delete& max_time(std::chrono::milliseconds max_time) {
154 _max_time = max_time;
155 return *this;
156 }
157
167 return _max_time;
168 }
169
184 _projection = std::move(projection);
185 return *this;
186 }
187
199
217 _ordering = std::move(ordering);
218 return *this;
219 }
220
232
247 _read_concern = std::move(read_concern);
248 return *this;
249 }
250
261 return _read_concern;
262 }
263
278 _write_concern = std::move(write_concern);
279 return *this;
280 }
281
292 return _write_concern;
293 }
294
309 _hint = std::move(index_hint);
310 return *this;
311 }
312
319 return _hint;
320 }
321
333 _let = std::move(let);
334 return *this;
335 }
336
346
361
371
372 private:
382};
383
384} // namespace options
385} // namespace v_noabi
386} // namespace mongocxx
387
388namespace mongocxx {
389namespace v_noabi {
390
397
404
405} // namespace v_noabi
406} // namespace mongocxx
407
409
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
find_one_and_delete()=default
Default initialization.
Options for a "findOneAndDelete" operation.
Definition find_one_and_delete_options.hpp:59
find_one_and_delete_options & comment(bsoncxx::v1::types::value v)
Set the "comment" field.
find_one_and_delete_options & max_time(std::chrono::milliseconds v)
Set the "maxTimeMS" field.
find_one_and_delete_options & hint(v1::hint v)
Set the "hint" field.
find_one_and_delete_options & write_concern(v1::write_concern v)
Set the "writeConcern" field.
find_one_and_delete_options & collation(bsoncxx::v1::document::value v)
Set the "collation" field.
find_one_and_delete_options & projection(bsoncxx::v1::document::value v)
Set the "projection" field.
find_one_and_delete_options & let(bsoncxx::v1::document::value v)
Set the "let" field.
find_one_and_delete_options & sort(bsoncxx::v1::document::value v)
Set the "sort" field.
find_one_and_delete_options & read_concern(v1::read_concern v)
Set the "readConcern" field.
The index to "hint" or force a MongoDB server to use when performing a query.
Definition hint.hpp:42
Used by mongocxx::v_noabi::collection.
Definition find_one_and_delete.hpp:49
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & collation() const
Retrieves the current collation for this operation.
Definition find_one_and_delete.hpp:136
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & projection() const
Gets the current projection set on this operation.
Definition find_one_and_delete.hpp:196
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 find_one_and_delete.hpp:368
find_one_and_delete & let(bsoncxx::v_noabi::document::view_or_value let)
Set the value of the let option.
Definition find_one_and_delete.hpp:332
bsoncxx::v_noabi::stdx::optional< v_noabi::read_concern > const & read_concern() const
Gets the current read concern.
Definition find_one_and_delete.hpp:260
find_one_and_delete & sort(bsoncxx::v_noabi::document::view_or_value ordering)
Sets the order to search for a matching document.
Definition find_one_and_delete.hpp:216
find_one_and_delete & collation(bsoncxx::v_noabi::document::view_or_value collation)
Sets the collation for this operation.
Definition find_one_and_delete.hpp:122
operator v1::find_one_and_delete_options() const
Convert to the mongocxx::v1 equivalent.
Definition find_one_and_delete.hpp:65
bsoncxx::v_noabi::stdx::optional< std::chrono::milliseconds > const & max_time() const
The current max_time setting.
Definition find_one_and_delete.hpp:166
find_one_and_delete & write_concern(v_noabi::write_concern write_concern)
Sets the write concern for this operation.
Definition find_one_and_delete.hpp:277
bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const & write_concern() const
Gets the current write concern.
Definition find_one_and_delete.hpp:291
find_one_and_delete & hint(v_noabi::hint index_hint)
Sets the index to use for this operation.
Definition find_one_and_delete.hpp:308
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const let() const
Gets the current value of the let option.
Definition find_one_and_delete.hpp:343
find_one_and_delete & comment(bsoncxx::v_noabi::types::bson_value::view_or_value comment)
Set the value of the comment option.
Definition find_one_and_delete.hpp:357
find_one_and_delete & read_concern(v_noabi::read_concern read_concern)
Sets the read concern for this operation.
Definition find_one_and_delete.hpp:246
find_one_and_delete()=default
Default initialization.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & sort() const
Gets the current sort ordering.
Definition find_one_and_delete.hpp:229
find_one_and_delete & projection(bsoncxx::v_noabi::document::view_or_value projection)
Sets a projection that limits the fields to return.
Definition find_one_and_delete.hpp:183
find_one_and_delete & max_time(std::chrono::milliseconds max_time)
Sets the maximum amount of time for this operation to run (server-side) in milliseconds.
Definition find_one_and_delete.hpp:153
bsoncxx::v_noabi::stdx::optional< v_noabi::hint > const & hint() const
Gets the current hint.
Definition find_one_and_delete.hpp:318
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 bsoncxx::v_noabi::document::view_or_value.
Declares mongocxx::v_noabi::options::find_one_and_delete.
Provides mongocxx::v1::find_one_and_delete_options.
#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.
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.