MongoDB C++ Driver mongocxx-3.1.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
mongocxx::options::find Class Reference

Class representing the optional arguments to a MongoDB query. More...

#include <find.hpp>

Public Member Functions

findallow_partial_results (bool allow_partial)
 Sets whether to allow partial results from a mongos if some shards are down (instead of throwing an error).
 
const stdx::optional< bool > & allow_partial_results () const
 Gets the current setting for allowing partial results from mongos.
 
findbatch_size (std::int32_t batch_size)
 Sets the number of documents to return per batch.
 
const stdx::optional< std::int32_t > & batch_size () const
 The current batch size setting.
 
findcollation (bsoncxx::document::view_or_value collation)
 Sets the collation for this operation.
 
const stdx::optional< bsoncxx::document::view_or_value > & collation () const
 Retrieves the current collation for this operation.
 
findcomment (bsoncxx::string::view_or_value comment)
 Attaches a comment to the query.
 
const stdx::optional< bsoncxx::string::view_or_value > & comment () const
 Gets the current comment attached to this query.
 
findcursor_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.
 
findhint (class hint index_hint)
 Sets the index to use for this operation.
 
const stdx::optional< class hint > & hint () const
 Gets the current hint.
 
findlimit (std::int32_t limit)
 Sets maximum number of documents to return.
 
const stdx::optional< std::int32_t > & limit () const
 Gets the current limit.
 
findmax (bsoncxx::document::view_or_value max)
 Gets the current exclusive upper 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.
 
findmax_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< 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.
 
findmax_scan (std::int32_t max)
 Sets the maximum number of documents or index keys to scan when executing the query.
 
const stdx::optional< std::int32_t > & max_scan () const
 Gets the current setting for the maximum number of documents to scan when executing the query.
 
findmax_time (std::chrono::milliseconds max_time)
 Sets the maximum amount of time for this operation to run (server-side) in milliseconds.
 
const stdx::optional< std::chrono::milliseconds > & max_time () const
 The current max_time_ms setting.
 
findmin (bsoncxx::document::view_or_value min)
 Gets the current inclusive lower bound for a specific index.
 
const stdx::optional< bsoncxx::document::view_or_value > & min () const
 Sets the current inclusive lower bound for a specific index.
 
findmodifiers (bsoncxx::document::view_or_value modifiers)
 Sets the meta-operators modifying the output or behavior of the query.
 
const stdx::optional< bsoncxx::document::view_or_value > & modifiers () const
 Gets the current query modifiers.
 
findno_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< bool > & no_cursor_timeout () const
 Gets the current no_cursor_timeout setting.
 
findprojection (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 > & projection () const
 Gets the current projection set on this query.
 
findread_preference (class read_preference rp)
 Sets the read_preference for this operation.
 
const stdx::optional< class read_preference > & read_preference () const
 The current read_preference for this operation.
 
findreturn_key (bool return_key)
 Sets whether to return the index keys associated with the query results, instead of the actual query results themselves.
 
const stdx::optional< bool > & return_key () const
 Gets the current setting for returning the index keys associated with the query results, instead of the actual query results themselves.
 
findshow_record_id (bool show_record_id)
 Sets whether to include the record identifier for each document in the query results.
 
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 results.
 
findskip (std::int32_t skip)
 Sets the number of documents to skip before returning results.
 
const stdx::optional< std::int32_t > & skip () const
 Gets the current number of documents to skip.
 
findsnapshot (bool snapshot)
 Sets whether snapshot mode should be used.
 
const stdx::optional< bool > & snapshot () const
 Gets the current setting for whether snapshot mode is being used.
 
findsort (bsoncxx::document::view_or_value ordering)
 The order in which to return matching documents.
 
const stdx::optional< bsoncxx::document::view_or_value > & sort () const
 Gets the current sort ordering for this query.
 
MONGOCXX_PRIVATE findmodifiers_clear ()
 Clears the modifiers member.
 

Detailed Description

Class representing the optional arguments to a MongoDB query.

Member Function Documentation

◆ allow_partial_results() [1/2]

const stdx::optional< bool > & mongocxx::options::find::allow_partial_results ( ) const

Gets the current setting for allowing partial results from mongos.

Returns
Whether partial results from mongos are allowed.
See also
http://docs.mongodb.org/meta-driver/latest/legacy/mongodb-wire-protocol/#op-query

◆ allow_partial_results() [2/2]

find & mongocxx::options::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 error).

Parameters
allow_partialWhether to allow partial results from mongos.
See also
http://docs.mongodb.org/meta-driver/latest/legacy/mongodb-wire-protocol/#op-query

◆ batch_size() [1/2]

const stdx::optional< std::int32_t > & mongocxx::options::find::batch_size ( ) const

The current batch size setting.

Returns
The current batch size.
See also
https://docs.mongodb.com/master/reference/method/cursor.batchSize/

◆ batch_size() [2/2]

find & mongocxx::options::find::batch_size ( std::int32_t  batch_size)

Sets the number of documents to return per batch.

Parameters
batch_sizeThe size of the batches to request.
See also
https://docs.mongodb.com/master/reference/method/cursor.batchSize/

◆ collation() [1/2]

const stdx::optional< bsoncxx::document::view_or_value > & mongocxx::options::find::collation ( ) const

Retrieves the current collation for this operation.

Returns
The current collation.
See also
https://docs.mongodb.com/master/reference/collation/

◆ collation() [2/2]

find & mongocxx::options::find::collation ( bsoncxx::document::view_or_value  collation)

Sets the collation for this operation.

Parameters
collationThe new collation.
See also
https://docs.mongodb.com/master/reference/collation/

◆ comment() [1/2]

const stdx::optional< bsoncxx::string::view_or_value > & mongocxx::options::find::comment ( ) const

Gets the current comment attached to this query.

Returns
The comment attached to this query.
See also
https://docs.mongodb.com/master/reference/operator/meta/comment/

◆ comment() [2/2]

find & mongocxx::options::find::comment ( bsoncxx::string::view_or_value  comment)

Attaches a comment to the query.

If $comment also exists in the modifiers document then the comment field overwrites $comment.

Parameters
commentThe comment to attach to this query.
See also
https://docs.mongodb.com/master/reference/operator/meta/comment/

◆ cursor_type() [1/2]

const stdx::optional< cursor::type > & mongocxx::options::find::cursor_type ( ) const

Gets the current cursor type.

Returns
The current cursor type.
See also
http://docs.mongodb.org/meta-driver/latest/legacy/mongodb-wire-protocol/#op-query

◆ cursor_type() [2/2]

find & mongocxx::options::find::cursor_type ( cursor::type  cursor_type)

Indicates the type of cursor to use for this query.

Parameters
cursor_typeThe cursor type to set.
See also
http://docs.mongodb.org/meta-driver/latest/legacy/mongodb-wire-protocol/#op-query

◆ hint() [1/2]

const stdx::optional< class hint > & mongocxx::options::find::hint ( ) const

Gets the current hint.

Returns
The current hint, if one is set.

◆ hint() [2/2]

find & mongocxx::options::find::hint ( class hint  index_hint)

Sets the index to use for this operation.

See also
https://docs.mongodb.com/master/reference/operator/meta/hint/
Note
if the server already has a cached shape for this query, it may ignore a hint.
Parameters
index_hintObject representing the index to use.

◆ limit() [1/2]

const stdx::optional< std::int32_t > & mongocxx::options::find::limit ( ) const

Gets the current limit.

Returns
The current limit.

◆ limit() [2/2]

find & mongocxx::options::find::limit ( std::int32_t  limit)

Sets maximum number of documents to return.

Parameters
limitThe maximum number of documents to return.

◆ max() [1/2]

const stdx::optional< bsoncxx::document::view_or_value > & mongocxx::options::find::max ( ) const

Sets the current exclusive upper bound for a specific index.

Returns
The exclusive upper bound for a specific index.
See also
https://docs.mongodb.com/master/reference/method/cursor.max/

◆ max() [2/2]

find & mongocxx::options::find::max ( bsoncxx::document::view_or_value  max)

Gets the current exclusive upper bound for a specific index.

Parameters
maxThe exclusive upper bound for a specific index.
See also
https://docs.mongodb.com/master/reference/method/cursor.max/

◆ max_await_time() [1/2]

const stdx::optional< std::chrono::milliseconds > & mongocxx::options::find::max_await_time ( ) const

The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query.

Returns
The current max await time (in milliseconds).

◆ max_await_time() [2/2]

find & mongocxx::options::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.

This only applies to a TAILABLE_AWAIT cursor. When the cursor is not a TAILABLE_AWAIT cursor, this option is ignored. The default on the server is to wait for one second.

Note
On servers < 3.2, this option is ignored.
Parameters
max_await_timeThe max amount of time (in milliseconds) to wait for new documents.
See also
https://docs.mongodb.com/master/reference/operator/meta/maxTimeMS

◆ max_scan() [1/2]

const stdx::optional< std::int32_t > & mongocxx::options::find::max_scan ( ) const

Gets the current setting for the maximum number of documents to scan when executing the query.

Returns
The current setting for the maximum number of documents or index keys to scan.
See also
https://docs.mongodb.com/master/reference/method/cursor.maxScan/

◆ max_scan() [2/2]

find & mongocxx::options::find::max_scan ( std::int32_t  max)

Sets the maximum number of documents or index keys to scan when executing the query.

Parameters
maxThe maximum number of documents or index keys to scan.
See also
https://docs.mongodb.com/master/reference/method/cursor.maxScan/

◆ max_time() [1/2]

const stdx::optional< std::chrono::milliseconds > & mongocxx::options::find::max_time ( ) const

The current max_time_ms setting.

Returns
The current max time (in milliseconds).
See also
https://docs.mongodb.com/master/reference/operator/meta/maxTimeMS

◆ max_time() [2/2]

find & mongocxx::options::find::max_time ( std::chrono::milliseconds  max_time)

Sets the maximum amount of time for this operation to run (server-side) in milliseconds.

Parameters
max_timeThe max amount of time (in milliseconds).
See also
https://docs.mongodb.com/master/reference/operator/meta/maxTimeMS

◆ min() [1/2]

const stdx::optional< bsoncxx::document::view_or_value > & mongocxx::options::find::min ( ) const

Sets the current inclusive lower bound for a specific index.

Returns
The inclusive lower bound for a specific index.
See also
https://docs.mongodb.com/master/reference/method/cursor.min/

◆ min() [2/2]

find & mongocxx::options::find::min ( bsoncxx::document::view_or_value  min)

Gets the current inclusive lower bound for a specific index.

Parameters
minThe inclusive lower bound for a specific index.
See also
https://docs.mongodb.com/master/reference/method/cursor.min/

◆ modifiers() [1/2]

const stdx::optional< bsoncxx::document::view_or_value > & mongocxx::options::find::modifiers ( ) const

Gets the current query modifiers.

Returns
The current query modifiers.
Deprecated:
The modifiers option has been deprecated, and has been replaced by new top-level options that have been introduced. For example, users should call find::snapshot() instead of calling find::modifiers() with a document containing a "$snapshot" field.

◆ modifiers() [2/2]

find & mongocxx::options::find::modifiers ( bsoncxx::document::view_or_value  modifiers)

Sets the meta-operators modifying the output or behavior of the query.

Parameters
modifiersThe query modifiers.
Deprecated:
The modifiers option has been deprecated, and has been replaced by new top-level options that have been introduced. For example, users should call find::snapshot() instead of calling find::modifiers() with a document containing a "$snapshot" field.
See also
https://docs.mongodb.com/master/reference/operator/query-modifier/

◆ modifiers_clear()

MONGOCXX_PRIVATE find & mongocxx::options::find::modifiers_clear ( )

Clears the modifiers member.

Internal-only.

◆ no_cursor_timeout() [1/2]

const stdx::optional< bool > & mongocxx::options::find::no_cursor_timeout ( ) const

Gets the current no_cursor_timeout setting.

Returns
The current no_cursor_timeout setting.
See also
http://docs.mongodb.org/meta-driver/latest/legacy/mongodb-wire-protocol/#op-query

◆ no_cursor_timeout() [2/2]

find & mongocxx::options::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.

Parameters
no_cursor_timeoutWhen true prevents the cursor from timing out.
See also
http://docs.mongodb.org/meta-driver/latest/legacy/mongodb-wire-protocol/#op-query

◆ projection() [1/2]

const stdx::optional< bsoncxx::document::view_or_value > & mongocxx::options::find::projection ( ) const

Gets the current projection set on this query.

Returns
The current projection.
See also
https://docs.mongodb.com/master/tutorial/project-fields-from-query-results/

◆ projection() [2/2]

find & mongocxx::options::find::projection ( bsoncxx::document::view_or_value  projection)

Sets a projection which limits the returned fields for all matching documents.

Parameters
projectionThe projection document.
See also
https://docs.mongodb.com/master/tutorial/project-fields-from-query-results/

◆ read_preference() [1/2]

const stdx::optional< class read_preference > & mongocxx::options::find::read_preference ( ) const

The current read_preference for this operation.

Returns
The current read_preference.
See also
https://docs.mongodb.com/master/core/read-preference/

◆ read_preference() [2/2]

find & mongocxx::options::find::read_preference ( class read_preference  rp)

Sets the read_preference for this operation.

Parameters
rpThe new read_preference.
See also
https://docs.mongodb.com/master/core/read-preference/

◆ return_key() [1/2]

const stdx::optional< bool > & mongocxx::options::find::return_key ( ) const

Gets the current setting for returning the index keys associated with the query results, instead of the actual query results themselves.

Returns
Whether index keys associated with the query results are returned, instead of the actual query results themselves.
See also
https://docs.mongodb.com/master/reference/method/cursor.returnKey/

◆ return_key() [2/2]

find & mongocxx::options::find::return_key ( bool  return_key)

Sets whether to return the index keys associated with the query results, instead of the actual query results themselves.

Parameters
return_keyWhether to return the index keys associated with the query results, instead of the actual query results themselves.
See also
https://docs.mongodb.com/master/reference/method/cursor.returnKey/

◆ show_record_id() [1/2]

const stdx::optional< bool > & mongocxx::options::find::show_record_id ( ) const

Gets the current setting for whether the record identifier is returned for each document in the query results.

Returns
Whether the record identifier is included.
See also
https://docs.mongodb.com/master/reference/method/cursor.showRecordId/

◆ show_record_id() [2/2]

find & mongocxx::options::find::show_record_id ( bool  show_record_id)

Sets whether to include the record identifier for each document in the query results.

Parameters
show_record_idWhether to include the record identifier.
See also
https://docs.mongodb.com/master/reference/method/cursor.showRecordId/

◆ skip() [1/2]

const stdx::optional< std::int32_t > & mongocxx::options::find::skip ( ) const

Gets the current number of documents to skip.

Returns
The number of documents to skip.
See also
https://docs.mongodb.com/master/reference/method/cursor.skip/

◆ skip() [2/2]

find & mongocxx::options::find::skip ( std::int32_t  skip)

Sets the number of documents to skip before returning results.

Parameters
skipThe number of documents to skip.
See also
https://docs.mongodb.com/master/reference/method/cursor.skip/

◆ snapshot() [1/2]

const stdx::optional< bool > & mongocxx::options::find::snapshot ( ) const

Gets the current setting for whether snapshot mode is being used.

Returns
Whether snapshot mode is being used.
See also
https://docs.mongodb.com/master/reference/method/cursor.snapshot/

◆ snapshot() [2/2]

find & mongocxx::options::find::snapshot ( bool  snapshot)

Sets whether snapshot mode should be used.

Parameters
snapshotWhether to enable snapshot mode.
See also
https://docs.mongodb.com/master/reference/method/cursor.snapshot/

◆ sort() [1/2]

const stdx::optional< bsoncxx::document::view_or_value > & mongocxx::options::find::sort ( ) const

Gets the current sort ordering for this query.

Returns
The current sort ordering.
See also
https://docs.mongodb.com/master/reference/method/cursor.sort/

◆ sort() [2/2]

find & mongocxx::options::find::sort ( bsoncxx::document::view_or_value  ordering)

The order in which to return matching documents.

If $orderby also exists in the modifiers document, the sort field takes precedence over $orderby.

Parameters
orderingDocument describing the order of the documents to be returned.
See also
https://docs.mongodb.com/master/reference/method/cursor.sort/

The documentation for this class was generated from the following file: