MongoDB C++ Driver  mongocxx-3.9.0
All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
find.hpp
1 // Copyright 2014 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 <chrono>
18 #include <cstdint>
19 
20 #include <bsoncxx/document/view_or_value.hpp>
21 #include <bsoncxx/stdx/optional.hpp>
22 #include <bsoncxx/string/view_or_value.hpp>
23 #include <bsoncxx/types/bson_value/view_or_value.hpp>
24 #include <mongocxx/cursor.hpp>
25 #include <mongocxx/hint.hpp>
26 #include <mongocxx/read_preference.hpp>
27 
28 #include <mongocxx/config/prelude.hpp>
29 
30 namespace mongocxx {
31 inline namespace v_noabi {
32 namespace options {
33 
37 class MONGOCXX_API find {
38  public:
56  find& allow_disk_use(bool allow_disk_use);
57 
65  const stdx::optional<bool>& allow_disk_use() const;
66 
80  find& allow_partial_results(bool allow_partial);
81 
89  const stdx::optional<bool>& allow_partial_results() const;
90 
103  find& batch_size(std::int32_t batch_size);
104 
112  const stdx::optional<std::int32_t>& batch_size() const;
113 
126  find& collation(bsoncxx::document::view_or_value collation);
127 
136  const stdx::optional<bsoncxx::document::view_or_value>& collation() const;
137 
153  find& comment(bsoncxx::string::view_or_value comment);
154 
164  const stdx::optional<bsoncxx::string::view_or_value>& comment() const;
165 
178  find& cursor_type(cursor::type cursor_type);
179 
187  const stdx::optional<cursor::type>& cursor_type() const;
188 
204  find& hint(class hint index_hint);
205 
213  const stdx::optional<class hint>& hint() const;
214 
227  find& let(bsoncxx::document::view_or_value let);
228 
237  const stdx::optional<bsoncxx::document::view_or_value> let() const;
238 
254 
265  const stdx::optional<bsoncxx::types::bson_value::view_or_value>& comment_option() const;
266 
278  find& limit(std::int64_t limit);
279 
287  const stdx::optional<std::int64_t>& limit() const;
288 
301  find& max(bsoncxx::document::view_or_value max);
302 
310  const stdx::optional<bsoncxx::document::view_or_value>& max() const;
311 
329  find& max_await_time(std::chrono::milliseconds max_await_time);
330 
339  const stdx::optional<std::chrono::milliseconds>& max_await_time() const;
340 
353  find& max_time(std::chrono::milliseconds max_time);
354 
362  const stdx::optional<std::chrono::milliseconds>& max_time() const;
363 
376  find& min(bsoncxx::document::view_or_value min);
377 
385  const stdx::optional<bsoncxx::document::view_or_value>& min() const;
386 
400  find& no_cursor_timeout(bool no_cursor_timeout);
401 
409  const stdx::optional<bool>& no_cursor_timeout() const;
410 
423  find& projection(bsoncxx::document::view_or_value projection);
424 
432  const stdx::optional<bsoncxx::document::view_or_value>& projection() const;
433 
447 
456  const stdx::optional<class read_preference>& read_preference() const;
457 
472  find& return_key(bool return_key);
473 
484  const stdx::optional<bool>& return_key() const;
485 
498  find& show_record_id(bool show_record_id);
499 
509  const stdx::optional<bool>& show_record_id() const;
510 
523  find& skip(std::int64_t skip);
524 
532  const stdx::optional<std::int64_t>& skip() const;
533 
547  find& sort(bsoncxx::document::view_or_value ordering);
548 
556  const stdx::optional<bsoncxx::document::view_or_value>& sort() const;
557 
558  private:
559  stdx::optional<bool> _allow_disk_use;
560  stdx::optional<bool> _allow_partial_results;
561  stdx::optional<std::int32_t> _batch_size;
562  stdx::optional<bsoncxx::document::view_or_value> _collation;
563  stdx::optional<bsoncxx::string::view_or_value> _comment;
564  stdx::optional<cursor::type> _cursor_type;
565  stdx::optional<class hint> _hint;
566  stdx::optional<bsoncxx::document::view_or_value> _let;
567  stdx::optional<bsoncxx::types::bson_value::view_or_value> _comment_option;
568  stdx::optional<std::int64_t> _limit;
569  stdx::optional<bsoncxx::document::view_or_value> _max;
570  stdx::optional<std::chrono::milliseconds> _max_await_time;
571  stdx::optional<std::chrono::milliseconds> _max_time;
572  stdx::optional<bsoncxx::document::view_or_value> _min;
573  stdx::optional<bool> _no_cursor_timeout;
574  stdx::optional<bsoncxx::document::view_or_value> _projection;
575  stdx::optional<class read_preference> _read_preference;
576  stdx::optional<bool> _return_key;
577  stdx::optional<bool> _show_record_id;
578  stdx::optional<std::int64_t> _skip;
579  stdx::optional<bsoncxx::document::view_or_value> _ordering;
580 };
581 
582 } // namespace options
583 } // namespace v_noabi
584 } // namespace mongocxx
585 
586 #include <mongocxx/config/postlude.hpp>
Class representing a view-or-value variant type.
Definition: view_or_value.hpp:29
Class representing a hint to be passed to a database operation.
Definition: hint.hpp:31
Class representing the optional arguments to a MongoDB query.
Definition: find.hpp:37
find & max_time(std::chrono::milliseconds max_time)
Sets the maximum amount of time for this operation to run (server-side) in milliseconds.
const stdx::optional< bool > & no_cursor_timeout() const
Gets the current no_cursor_timeout setting.
const stdx::optional< class read_preference > & read_preference() const
The current read_preference for this operation.
find & allow_disk_use(bool allow_disk_use)
Enables writing to temporary files on the server.
find & cursor_type(cursor::type cursor_type)
Indicates the type of cursor to use for this query.
const stdx::optional< cursor::type > & cursor_type() const
Gets the current cursor type.
const stdx::optional< bool > & return_key() const
Gets the current setting for returning the index keys associated with the query results,...
find & return_key(bool return_key)
Sets whether to return the index keys associated with the query results, instead of the actual query ...
find & let(bsoncxx::document::view_or_value let)
Set the value of the let option.
const stdx::optional< bsoncxx::document::view_or_value > & sort() const
Gets the current sort ordering for this query.
find & limit(std::int64_t limit)
Sets maximum number of documents to return.
find & allow_partial_results(bool allow_partial)
Sets whether to allow partial results from a mongos if some shards are down (instead of throwing an e...
const stdx::optional< bsoncxx::types::bson_value::view_or_value > & comment_option() const
Gets the current value of the comment option.
const stdx::optional< std::chrono::milliseconds > & max_time() const
The current max_time_ms setting.
find & comment_option(bsoncxx::types::bson_value::view_or_value comment)
Set the value of the comment option.
find & show_record_id(bool show_record_id)
Sets whether to include the record identifier for each document in the query results.
find & collation(bsoncxx::document::view_or_value collation)
Sets the collation for this operation.
const stdx::optional< bool > & show_record_id() const
Gets the current setting for whether the record identifier is returned for each document in the query...
const stdx::optional< bool > & allow_partial_results() const
Gets the current setting for allowing partial results from mongos.
const stdx::optional< std::int64_t > & skip() const
Gets the current number of documents to skip.
const stdx::optional< bsoncxx::document::view_or_value > & min() const
Sets the current inclusive lower bound for a specific index.
const stdx::optional< bsoncxx::document::view_or_value > & max() const
Sets the current exclusive upper bound for a specific index.
find & skip(std::int64_t skip)
Sets the number of documents to skip before returning results.
find & read_preference(class read_preference rp)
Sets the read_preference for this operation.
find & comment(bsoncxx::string::view_or_value comment)
Attaches a comment to the query.
find & hint(class hint index_hint)
Sets the index to use for this operation.
find & min(bsoncxx::document::view_or_value min)
Gets the current inclusive lower bound for a specific index.
find & sort(bsoncxx::document::view_or_value ordering)
The order in which to return matching documents.
const stdx::optional< bsoncxx::document::view_or_value > let() const
Gets the current value of the let option.
find & max_await_time(std::chrono::milliseconds max_await_time)
The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query...
const stdx::optional< class hint > & hint() const
Gets the current hint.
const stdx::optional< bsoncxx::document::view_or_value > & projection() const
Gets the current projection set on this query.
find & max(bsoncxx::document::view_or_value max)
Gets the current exclusive upper bound for a specific index.
find & projection(bsoncxx::document::view_or_value projection)
Sets a projection which limits the returned fields for all matching documents.
const stdx::optional< bsoncxx::document::view_or_value > & collation() const
Retrieves the current collation for this operation.
find & no_cursor_timeout(bool no_cursor_timeout)
Sets the cursor flag to prevent cursor from timing out server-side due to a period of inactivity.
const stdx::optional< bsoncxx::string::view_or_value > & comment() const
Gets the current comment attached to this query.
const stdx::optional< std::chrono::milliseconds > & max_await_time() const
The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query...
find & batch_size(std::int32_t batch_size)
Sets the number of documents to return per batch.
const stdx::optional< bool > & allow_disk_use() const
Gets the current setting for allowing disk use on the server.
const stdx::optional< std::int64_t > & limit() const
Gets the current limit.
const stdx::optional< std::int32_t > & batch_size() const
The current batch size setting.
Class representing a preference for how the driver routes read operations to members of a replica set...
Definition: read_preference.hpp:67
The top-level namespace for mongocxx library entities.
Definition: bulk_write.hpp:24