MongoDB C++ Driver 4.4.0
Loading...
Searching...
No Matches
distinct.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/distinct-fwd.hpp> // IWYU pragma: export
18
19//
20
21#include <mongocxx/v1/distinct_options.hpp> // IWYU pragma: export
22
23#include <chrono>
24#include <cstdint> // IWYU pragma: keep: backward compatibility, to be removed.
25#include <string> // IWYU pragma: keep: backward compatibility, to be removed.
26#include <utility>
27
35
38
40
41namespace mongocxx {
42namespace v_noabi {
43namespace options {
44
48class distinct {
49 public:
53 distinct() = default;
54
59
63 explicit operator v1::distinct_options() const {
65
67
68 if (_collation) {
69 ret.collation(bsoncxx::v1::document::value{to_v1(_collation->view())});
70 }
71
72 if (_max_time) {
73 ret.max_time(*_max_time);
74 }
75
76 if (_comment) {
77 ret.comment(bsoncxx::v1::types::value{to_v1(_comment->view())});
78 }
79
80 if (_read_preference) {
81 ret.read_preference(to_v1(*_read_preference));
82 }
83
84 if (_read_concern) {
85 ret.read_concern(to_v1(*_read_concern));
86 }
87
88 return ret;
89 }
90
105 _collation = std::move(collation);
106 return *this;
107 }
108
121
135 distinct& max_time(std::chrono::milliseconds max_time) {
136 _max_time = max_time;
137 return *this;
138 }
139
149 return _max_time;
150 }
151
166 _comment = std::move(comment);
167 return *this;
168 }
169
181
196 _read_preference = std::move(rp);
197 return *this;
198 }
199
209 return _read_preference;
210 }
211
226 _read_concern = std::move(rc);
227 return *this;
228 }
229
239 return _read_concern;
240 }
241
242 private:
248};
249
250} // namespace options
251} // namespace v_noabi
252} // namespace mongocxx
253
254namespace mongocxx {
255namespace v_noabi {
256
261 return {std::move(v)};
262}
263
269
270} // namespace v_noabi
271} // namespace mongocxx
272
274
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
distinct()=default
Default initialization.
Options for a "distinct" command.
Definition distinct_options.hpp:53
distinct_options & comment(bsoncxx::v1::types::value v)
Set the "comment" field.
distinct_options & read_preference(v1::read_preference v)
Set the "readPreference" field.
distinct_options & max_time(std::chrono::milliseconds v)
Set the "maxTimeMS" field.
distinct_options & collation(bsoncxx::v1::document::value v)
Set the "collation" field.
distinct_options & read_concern(v1::read_concern v)
Set the "readConcern" field.
Used by mongocxx::v_noabi::collection.
Definition distinct.hpp:48
bsoncxx::v_noabi::stdx::optional< v_noabi::read_preference > const & read_preference() const
The current read_preference for this operation.
Definition distinct.hpp:208
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::types::bson_value::view_or_value > const & comment() const
The current comment for this operation.
Definition distinct.hpp:178
bsoncxx::v_noabi::stdx::optional< v_noabi::read_concern > const & read_concern() const
The current read_concern for this operation.
Definition distinct.hpp:238
distinct & read_preference(v_noabi::read_preference rp)
Sets the read_preference for this operation.
Definition distinct.hpp:195
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & collation() const
Retrieves the current collation for this operation.
Definition distinct.hpp:118
distinct()=default
Default initialization.
operator v1::distinct_options() const
Convert to the mongocxx::v1 equivalent.
Definition distinct.hpp:63
distinct & collation(bsoncxx::v_noabi::document::view_or_value collation)
Sets the collation for this operation.
Definition distinct.hpp:104
distinct & read_concern(v_noabi::read_concern rc)
Sets the read_concern for this operation.
Definition distinct.hpp:225
distinct & max_time(std::chrono::milliseconds max_time)
Sets the maximum amount of time for this operation to run (server-side) in milliseconds.
Definition distinct.hpp:135
bsoncxx::v_noabi::stdx::optional< std::chrono::milliseconds > const & max_time() const
The current max_time setting.
Definition distinct.hpp:148
distinct & comment(bsoncxx::v_noabi::types::bson_value::view_or_value comment)
Sets the comment for this operation.
Definition distinct.hpp:165
Controls the consistency and isolation properties of data read from replica sets and sharded clusters...
Definition read_concern.hpp:54
Describes how MongoDB clients route read operations to the members of a replica set or sharded cluste...
Definition read_preference.hpp:59
Declares mongocxx::v_noabi::options::distinct.
Provides mongocxx::v1::distinct_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.
Provides bsoncxx::v_noabi::types::bson_value::view_or_value.
Provides bsoncxx::v_noabi::document::value.
Provides bsoncxx::v_noabi::document::view.
Provides std::optional-related polyfills for library API usage.
Provides bsoncxx::v_noabi::types::bson_value::value.
Provides bsoncxx::v_noabi::types::bson_value::view.
Provides mongocxx::v_noabi::read_concern.
Provides mongocxx::v_noabi::read_preference.