Loading...
Searching...
No Matches
mongocxx::options::find Class Reference

`#include <mongocxx/v_noabi/mongocxx/options/find.hpp>`

## Description

Used by MongoDB find operations.

## Public Member Functions

| find ()=default
| Default initialization.
| find (v1::find_options opts)
| Construct with the mongocxx::v1 equivalent.
bsoncxx::v_noabi::stdx::optional< bool > const & | allow_disk_use () const
| Gets the current setting for allowing disk use on the server.
find & | allow_disk_use (bool allow_disk_use)
| Enables writing to temporary files on the server. When set to true, the server can write temporary data to disk while executing the find operation.
bsoncxx::v_noabi::stdx::optional< bool > const & | allow_partial_results () const
| Gets the current setting for allowing partial results from mongos.
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).
bsoncxx::v_noabi::stdx::optional< std::int32_t > const & | batch_size () const
| The current batch size setting.
find & | batch_size (std::int32_t batch_size)
| Sets the number of documents to return per batch.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & | collation () const
| Retrieves the current collation for this operation.
find & | collation (bsoncxx::v_noabi::document::view_or_value collation)
| Sets the collation for this operation.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::string::view_or_value > const & | comment () const
| Gets the current comment attached to this query.
find & | comment (bsoncxx::v_noabi::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.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::types::bson_value::view_or_value > const & | comment_option () const
| Gets the current value of the comment option.
find & | comment_option (bsoncxx::v_noabi::types::bson_value::view_or_value comment)
| Set the value of the comment option.
bsoncxx::v_noabi::stdx::optional< cursor::type > const & | cursor_type () const
| Gets the current cursor type.
find & | cursor_type (cursor::type cursor_type)
| Indicates the type of cursor to use for this query.
bsoncxx::v_noabi::stdx::optional< v_noabi::hint > const & | hint () const
| Gets the current hint.
find & | hint (v_noabi::hint index_hint)
| Sets the index to use for this operation.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const | let () const
| Gets the current value of the let option.
find & | let (bsoncxx::v_noabi::document::view_or_value let)
| Set the value of the let option.
bsoncxx::v_noabi::stdx::optional< std::int64_t > const & | limit () const
| Gets the current limit.
find & | limit (std::int64_t limit)
| Sets maximum number of documents to return.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & | max () const
| Sets the current exclusive upper bound for a specific index.
find & | max (bsoncxx::v_noabi::document::view_or_value max)
| Gets the current exclusive upper bound for a specific index.
bsoncxx::v_noabi::stdx::optional< std::chrono::milliseconds > const & | max_await_time () const
| The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query.
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.
bsoncxx::v_noabi::stdx::optional< std::chrono::milliseconds > const & | max_time () const
| The current max_time_ms setting.
find & | max_time (std::chrono::milliseconds max_time)
| Sets the maximum amount of time for this operation to run (server-side) in milliseconds.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & | min () const
| Sets the current inclusive lower bound for a specific index.
find & | min (bsoncxx::v_noabi::document::view_or_value min)
| Gets the current inclusive lower bound for a specific index.
bsoncxx::v_noabi::stdx::optional< bool > const & | no_cursor_timeout () const
| Gets the current no_cursor_timeout setting.
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.
| operator v1::find_options () const
| Convert to the mongocxx::v1 equivalent.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & | projection () const
| Gets the current projection set on this query.
find & | projection (bsoncxx::v_noabi::document::view_or_value projection)
| Sets a projection which limits the returned fields for all matching documents.
bsoncxx::v_noabi::stdx::optional< v_noabi::read_concern > const & | read_concern () const
| The current read_concern for this operation.
find & | read_concern (v_noabi::read_concern rc)
| Sets the read_concern for this operation.
bsoncxx::v_noabi::stdx::optional< v_noabi::read_preference > const & | read_preference () const
| The current read_preference for this operation.
find & | read_preference (v_noabi::read_preference rp)
| Sets the read_preference for this operation.
bsoncxx::v_noabi::stdx::optional< bool > const & | return_key () const
| Gets the current setting for returning the index keys associated with the query results, instead of the actual query results themselves.
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.
bsoncxx::v_noabi::stdx::optional< bool > const & | show_record_id () const
| Gets the current setting for whether the record identifier is returned for each document in the query results.
find & | show_record_id (bool show_record_id)
| Sets whether to include the record identifier for each document in the query results.
bsoncxx::v_noabi::stdx::optional< std::int64_t > const & | skip () const
| Gets the current number of documents to skip.
find & | skip (std::int64_t skip)
| Sets the number of documents to skip before returning results.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & | sort () const
| Gets the current sort ordering for this query.
find & | sort (bsoncxx::v_noabi::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.

## Constructor & Destructor Documentation

## find() [1/2]

mongocxx::v_noabi::options::find::find | ( |  | ) |

default

Default initialization.

## find() [2/2]

mongocxx::v_noabi::options::find::find | ( | v1::find_options | opts | ) |

Construct with the mongocxx::v1 equivalent.

## Member Function Documentation

## allow_disk_use() [1/2]

bsoncxx::v_noabi::stdx::optional< bool > const & mongocxx::v_noabi::options::find::allow_disk_use | ( |  | ) | const

inline

Gets the current setting for allowing disk use on the server.

This option may only be used with MongoDB version 4.4 or later.

Returns
  Whether disk use on the server is allowed.

## allow_disk_use() [2/2]

find & mongocxx::v_noabi::options::find::allow_disk_use | ( | bool | allow_disk_use | ) |

inline

Enables writing to temporary files on the server. When set to true, the server can write temporary data to disk while executing the find operation.

This option is sent only if the caller explicitly provides a value. The default is to not send a value.

This option may only be used with MongoDB version 4.4 or later.

Parameters

  allow_disk_use | Whether to allow writing temporary files on the server.

Returns
  A reference to this object to facilitate method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## allow_partial_results() [1/2]

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

inline

Gets the current setting for allowing partial results from mongos.

Returns
  Whether partial results from mongos are allowed.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## allow_partial_results() [2/2]

find & mongocxx::v_noabi::options::find::allow_partial_results | ( | bool | allow_partial | ) |

inline

Sets whether to allow partial results from a mongos if some shards are down (instead of throwing an error).

Parameters

  allow_partial | Whether to allow partial results from mongos.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## batch_size() [1/2]

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

inline

The current batch size setting.

Returns
  The current batch size.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## batch_size() [2/2]

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

inline

Sets the number of documents to return per batch.

Parameters

  batch_size | The size of the batches to request.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## collation() [1/2]

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

inline

Retrieves the current collation for this operation.

Returns
  The current collation.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## collation() [2/2]

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

inline

Sets the collation for this operation.

Parameters

  collation | The new collation.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## comment() [1/2]

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

inline

Gets the current comment attached to this query.

Deprecated
  use comment_option instead.

Returns
  The comment attached to this query.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## comment() [2/2]

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

inline

Attaches a comment to the query. If $comment also exists in the modifiers document then the comment field overwrites $comment.

Deprecated
  use comment_option instead.

Parameters

  comment | The comment to attach to this query.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## comment_option() [1/2]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::types::bson_value::view_or_value > const & mongocxx::v_noabi::options::find::comment_option | ( |  | ) | const

inline

Gets the current value of the comment option.

Note
  Not to be confused with the $comment query modifier.

Returns
  The current comment option.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## comment_option() [2/2]

find & mongocxx::v_noabi::options::find::comment_option | ( | bsoncxx::v_noabi::types::bson_value::view_or_value | comment | ) |

inline

Set the value of the comment option.

Note
  Not to be confused with the $comment query modifier.

Parameters

  comment | The new comment option.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## cursor_type() [1/2]

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

inline

Gets the current cursor type.

Returns
  The current cursor type.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## cursor_type() [2/2]

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

inline

Indicates the type of cursor to use for this query.

Parameters

  cursor_type | The cursor type to set.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## hint() [1/2]

bsoncxx::v_noabi::stdx::optional< v_noabi::hint > const & mongocxx::v_noabi::options::find::hint | ( |  | ) | const

inline

Gets the current hint.

Returns
  The current hint, if one is set.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## hint() [2/2]

find & mongocxx::v_noabi::options::find::hint | ( | v_noabi::hint | index_hint | ) |

inline

Sets the index to use for this operation.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

Note
  if the server already has a cached shape for this query, it may ignore a hint.

Parameters

  index_hint | Object representing the index to use.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

## let() [1/2]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const mongocxx::v_noabi::options::find::let | ( |  | ) | const

inline

Gets the current value of the let option.

Returns
  The current let option.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## let() [2/2]

find & mongocxx::v_noabi::options::find::let | ( | bsoncxx::v_noabi::document::view_or_value | let | ) |

inline

Set the value of the let option.

Parameters

  let | The new let option.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## limit() [1/2]

bsoncxx::v_noabi::stdx::optional< std::int64_t > const & mongocxx::v_noabi::options::find::limit | ( |  | ) | const

inline

Gets the current limit.

Returns
  The current limit.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## limit() [2/2]

find & mongocxx::v_noabi::options::find::limit | ( | std::int64_t | limit | ) |

inline

Sets maximum number of documents to return.

Parameters

  limit | The maximum number of documents to return.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## max() [1/2]

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

inline

Sets the current exclusive upper bound for a specific index.

Returns
  The exclusive upper bound for a specific index.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## max() [2/2]

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

inline

Gets the current exclusive upper bound for a specific index.

Parameters

  max | The exclusive upper bound for a specific index.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## max_await_time() [1/2]

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

inline

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).

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## max_await_time() [2/2]

find & mongocxx::v_noabi::options::find::max_await_time | ( | std::chrono::milliseconds | max_await_time | ) |

inline

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_time | The max amount of time (in milliseconds) to wait for new documents.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## max_time() [1/2]

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

inline

The current max_time_ms setting.

Returns
  The current max time (in milliseconds).

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## max_time() [2/2]

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

inline

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

Parameters

  max_time | The max amount of time (in milliseconds).

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## min() [1/2]

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

inline

Sets the current inclusive lower bound for a specific index.

Returns
  The inclusive lower bound for a specific index.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## min() [2/2]

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

inline

Gets the current inclusive lower bound for a specific index.

Parameters

  min | The inclusive lower bound for a specific index.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## no_cursor_timeout() [1/2]

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

inline

Gets the current no_cursor_timeout setting.

Returns
  The current no_cursor_timeout setting.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## no_cursor_timeout() [2/2]

find & mongocxx::v_noabi::options::find::no_cursor_timeout | ( | bool | no_cursor_timeout | ) |

inline

Sets the cursor flag to prevent cursor from timing out server-side due to a period of inactivity.

Parameters

  no_cursor_timeout | When true prevents the cursor from timing out.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## operator v1::find_options()

mongocxx::v_noabi::options::find::operator v1::find_options | ( |  | ) | const

inline explicit

Convert to the mongocxx::v1 equivalent.

Note
  The comment field is initialized with this->comment_option() (BSON type value) when set; otherwise, by this->comment() (std::string) when set; otherwise, it is unset.

## projection() [1/2]

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

inline

Gets the current projection set on this query.

Returns
  The current projection.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## projection() [2/2]

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

inline

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

Parameters

  projection | The projection document.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## read_concern() [1/2]

bsoncxx::v_noabi::stdx::optional< v_noabi::read_concern > const & mongocxx::v_noabi::options::find::read_concern | ( |  | ) | const

inline

The current read_concern for this operation.

Returns
  The current read_concern.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## read_concern() [2/2]

find & mongocxx::v_noabi::options::find::read_concern | ( | v_noabi::read_concern | rc | ) |

inline

Sets the read_concern for this operation.

Parameters

  rc | The new read_concern.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## read_preference() [1/2]

bsoncxx::v_noabi::stdx::optional< v_noabi::read_preference > const & mongocxx::v_noabi::options::find::read_preference | ( |  | ) | const

inline

The current read_preference for this operation.

Returns
  The current read_preference.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## read_preference() [2/2]

find & mongocxx::v_noabi::options::find::read_preference | ( | v_noabi::read_preference | rp | ) |

inline

Sets the read_preference for this operation.

Parameters

  rp | The new read_preference.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## return_key() [1/2]

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

inline

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://www.mongodb.com/docs/manual/reference/command/find/

## return_key() [2/2]

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

inline

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

Parameters

  return_key | Whether to return the index keys associated with the query results, instead of the actual query results themselves.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## show_record_id() [1/2]

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

inline

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://www.mongodb.com/docs/manual/reference/command/find/

## show_record_id() [2/2]

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

inline

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

Parameters

  show_record_id | Whether to include the record identifier.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## skip() [1/2]

bsoncxx::v_noabi::stdx::optional< std::int64_t > const & mongocxx::v_noabi::options::find::skip | ( |  | ) | const

inline

Gets the current number of documents to skip.

Returns
  The number of documents to skip.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## skip() [2/2]

find & mongocxx::v_noabi::options::find::skip | ( | std::int64_t | skip | ) |

inline

Sets the number of documents to skip before returning results.

Parameters

  skip | The number of documents to skip.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## sort() [1/2]

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

inline

Gets the current sort ordering for this query.

Returns
  The current sort ordering.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

## sort() [2/2]

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

inline

The order in which to return matching documents. If $orderby also exists in the modifiers document, the sort field takes precedence over $orderby.

Parameters

  ordering | Document describing the order of the documents to be returned.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

See also
  - https://www.mongodb.com/docs/manual/reference/command/find/

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

- mongocxx/v_noabi/mongocxx/options/find.hpp