MongoDB C++ Driver  mongocxx-3.6.2
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 <mongocxx/cursor.hpp>
24 #include <mongocxx/hint.hpp>
25 #include <mongocxx/read_preference.hpp>
26 
27 #include <mongocxx/config/prelude.hpp>
28 
29 namespace mongocxx {
30 MONGOCXX_INLINE_NAMESPACE_BEGIN
31 namespace options {
32 
36 class MONGOCXX_API find {
37  public:
55  find& allow_disk_use(bool allow_disk_use);
56 
64  const stdx::optional<bool>& allow_disk_use() const;
65 
79  find& allow_partial_results(bool allow_partial);
80 
88  const stdx::optional<bool>& allow_partial_results() const;
89 
102  find& batch_size(std::int32_t batch_size);
103 
111  const stdx::optional<std::int32_t>& batch_size() const;
112 
126 
135  const stdx::optional<bsoncxx::document::view_or_value>& collation() const;
136 
151 
159  const stdx::optional<bsoncxx::string::view_or_value>& comment() const;
160 
173  find& cursor_type(cursor::type cursor_type);
174 
182  const stdx::optional<cursor::type>& cursor_type() const;
183 
199  find& hint(class hint index_hint);
200 
208  const stdx::optional<class hint>& hint() const;
209 
221  find& limit(std::int64_t limit);
222 
230  const stdx::optional<std::int64_t>& limit() const;
231 
245 
253  const stdx::optional<bsoncxx::document::view_or_value>& max() const;
254 
272  find& max_await_time(std::chrono::milliseconds max_await_time);
273 
282  const stdx::optional<std::chrono::milliseconds>& max_await_time() const;
283 
296  find& max_time(std::chrono::milliseconds max_time);
297 
305  const stdx::optional<std::chrono::milliseconds>& max_time() const;
306 
320 
328  const stdx::optional<bsoncxx::document::view_or_value>& min() const;
329 
343  find& no_cursor_timeout(bool no_cursor_timeout);
344 
352  const stdx::optional<bool>& no_cursor_timeout() const;
353 
367 
375  const stdx::optional<bsoncxx::document::view_or_value>& projection() const;
376 
390 
399  const stdx::optional<class read_preference>& read_preference() const;
400 
415  find& return_key(bool return_key);
416 
427  const stdx::optional<bool>& return_key() const;
428 
441  find& show_record_id(bool show_record_id);
442 
452  const stdx::optional<bool>& show_record_id() const;
453 
466  find& skip(std::int64_t skip);
467 
475  const stdx::optional<std::int64_t>& skip() const;
476 
491 
499  const stdx::optional<bsoncxx::document::view_or_value>& sort() const;
500 
501  private:
502  stdx::optional<bool> _allow_disk_use;
503  stdx::optional<bool> _allow_partial_results;
504  stdx::optional<std::int32_t> _batch_size;
505  stdx::optional<bsoncxx::document::view_or_value> _collation;
506  stdx::optional<bsoncxx::string::view_or_value> _comment;
507  stdx::optional<cursor::type> _cursor_type;
508  stdx::optional<class hint> _hint;
509  stdx::optional<std::int64_t> _limit;
510  stdx::optional<bsoncxx::document::view_or_value> _max;
511  stdx::optional<std::chrono::milliseconds> _max_await_time;
512  stdx::optional<std::chrono::milliseconds> _max_time;
513  stdx::optional<bsoncxx::document::view_or_value> _min;
514  stdx::optional<bool> _no_cursor_timeout;
515  stdx::optional<bsoncxx::document::view_or_value> _projection;
516  stdx::optional<class read_preference> _read_preference;
517  stdx::optional<bool> _return_key;
518  stdx::optional<bool> _show_record_id;
519  stdx::optional<std::int64_t> _skip;
520  stdx::optional<bsoncxx::document::view_or_value> _ordering;
521 };
522 
523 } // namespace options
524 MONGOCXX_INLINE_NAMESPACE_END
525 } // namespace mongocxx
526 
527 #include <mongocxx/config/postlude.hpp>
mongocxx::options::find::return_key
find & return_key(bool return_key)
Sets whether to return the index keys associated with the query results, instead of the actual query ...
mongocxx::options::find::batch_size
const stdx::optional< std::int32_t > & batch_size() const
The current batch size setting.
mongocxx::options::find::skip
find & skip(std::int64_t skip)
Sets the number of documents to skip before returning results.
mongocxx
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
mongocxx::options::find::min
const stdx::optional< bsoncxx::document::view_or_value > & min() const
Sets the current inclusive lower bound for a specific index.
mongocxx::options::find::max_time
const stdx::optional< std::chrono::milliseconds > & max_time() const
The current max_time_ms setting.
mongocxx::options::find::skip
const stdx::optional< std::int64_t > & skip() const
Gets the current number of documents to skip.
mongocxx::options::find::return_key
const stdx::optional< bool > & return_key() const
Gets the current setting for returning the index keys associated with the query results,...
bsoncxx::view_or_value< document::view, document::value >
mongocxx::options::find::comment
find & comment(bsoncxx::string::view_or_value comment)
Attaches a comment to the query.
mongocxx::options::find::collation
const stdx::optional< bsoncxx::document::view_or_value > & collation() const
Retrieves the current collation for this operation.
mongocxx::options::find::read_preference
find & read_preference(class read_preference rp)
Sets the read_preference for this operation.
mongocxx::options::find::sort
find & sort(bsoncxx::document::view_or_value ordering)
The order in which to return matching documents.
mongocxx::options::find::cursor_type
find & cursor_type(cursor::type cursor_type)
Indicates the type of cursor to use for this query.
mongocxx::options::find::max
const stdx::optional< bsoncxx::document::view_or_value > & max() const
Sets the current exclusive upper bound for a specific index.
mongocxx::options::find::collation
find & collation(bsoncxx::document::view_or_value collation)
Sets the collation for this operation.
mongocxx::options::find::hint
find & hint(class hint index_hint)
Sets the index to use for this operation.
mongocxx::options::find::sort
const stdx::optional< bsoncxx::document::view_or_value > & sort() const
Gets the current sort ordering for this query.
mongocxx::options::find::comment
const stdx::optional< bsoncxx::string::view_or_value > & comment() const
Gets the current comment attached to this query.
mongocxx::options::find::allow_disk_use
const stdx::optional< bool > & allow_disk_use() const
Gets the current setting for allowing disk use on the server.
mongocxx::read_preference
Class representing a preference for how the driver routes read operations to members of a replica set...
Definition: read_preference.hpp:62
mongocxx::options::find::allow_partial_results
const stdx::optional< bool > & allow_partial_results() const
Gets the current setting for allowing partial results from mongos.
mongocxx::options::find::allow_disk_use
find & allow_disk_use(bool allow_disk_use)
Enables writing to temporary files on the server.
bsoncxx::string::view_or_value
Class representing a view-or-value variant type for strings.
Definition: view_or_value.hpp:36
mongocxx::options::find::limit
find & limit(std::int64_t limit)
Sets maximum number of documents to return.
mongocxx::options::find::no_cursor_timeout
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.
mongocxx::options::find
Class representing the optional arguments to a MongoDB query.
Definition: find.hpp:36
mongocxx::options::find::projection
find & projection(bsoncxx::document::view_or_value projection)
Sets a projection which limits the returned fields for all matching documents.
mongocxx::options::find::cursor_type
const stdx::optional< cursor::type > & cursor_type() const
Gets the current cursor type.
mongocxx::options::find::max_time
find & max_time(std::chrono::milliseconds max_time)
Sets the maximum amount of time for this operation to run (server-side) in milliseconds.
mongocxx::options::find::max
find & max(bsoncxx::document::view_or_value max)
Gets the current exclusive upper bound for a specific index.
mongocxx::hint
Class representing a hint to be passed to a database operation.
Definition: hint.hpp:32
mongocxx::options::find::projection
const stdx::optional< bsoncxx::document::view_or_value > & projection() const
Gets the current projection set on this query.
mongocxx::options::find::limit
const stdx::optional< std::int64_t > & limit() const
Gets the current limit.
mongocxx::options::find::allow_partial_results
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...
mongocxx::options::find::read_preference
const stdx::optional< class read_preference > & read_preference() const
The current read_preference for this operation.
mongocxx::options::find::batch_size
find & batch_size(std::int32_t batch_size)
Sets the number of documents to return per batch.
mongocxx::options::find::min
find & min(bsoncxx::document::view_or_value min)
Gets the current inclusive lower bound for a specific index.
mongocxx::options::find::show_record_id
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...
mongocxx::options::find::max_await_time
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...
mongocxx::options::find::hint
const stdx::optional< class hint > & hint() const
Gets the current hint.
mongocxx::options::find::max_await_time
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...
mongocxx::options::find::show_record_id
find & show_record_id(bool show_record_id)
Sets whether to include the record identifier for each document in the query results.
mongocxx::options::find::no_cursor_timeout
const stdx::optional< bool > & no_cursor_timeout() const
Gets the current no_cursor_timeout setting.