MongoDB C++ Driver  mongocxx-3.4.0
Public Member Functions | List of all members
mongocxx::options::find_one_and_update Class Reference

Class representing the optional arguments to a MongoDB find_and_modify update operation. More...

#include <find_one_and_update.hpp>

Public Member Functions

find_one_and_updatecollation (bsoncxx::document::view_or_value collation)
 Sets the collation for this operation. More...
 
const stdx::optional< bsoncxx::document::view_or_value > & collation () const
 Retrieves the current collation for this operation. More...
 
find_one_and_updatebypass_document_validation (bool bypass_document_validation)
 Whether or not to bypass document validation for this operation. More...
 
const stdx::optional< bool > & bypass_document_validation () const
 The current setting for bypassing document validation. More...
 
find_one_and_updatemax_time (std::chrono::milliseconds max_time)
 Sets the maximum amount of time for this operation to run (server-side) in milliseconds. More...
 
const stdx::optional< std::chrono::milliseconds > & max_time () const
 The current max_time setting. More...
 
find_one_and_updateprojection (bsoncxx::document::view_or_value projection)
 Sets a projection, which limits the fields to return. More...
 
const stdx::optional< bsoncxx::document::view_or_value > & projection () const
 Gets the current projection for this operation. More...
 
find_one_and_updatereturn_document (return_document return_document)
 Set the desired version of the updated document to return, either the original document, or the updated. More...
 
const stdx::optional< mongocxx::options::return_document > & return_document () const
 Which version of the updated document to return. More...
 
find_one_and_updatesort (bsoncxx::document::view_or_value ordering)
 Sets the order by which to search the collection for a matching document. More...
 
const stdx::optional< bsoncxx::document::view_or_value > & sort () const
 Gets the current sort ordering. More...
 
find_one_and_updateupsert (bool upsert)
 Sets the upsert flag on the operation. More...
 
const stdx::optional< bool > & upsert () const
 Gets the current upsert setting. More...
 
find_one_and_updatewrite_concern (mongocxx::write_concern write_concern)
 Sets the write concern for this operation. More...
 
const stdx::optional< mongocxx::write_concern > & write_concern () const
 Gets the current write concern. More...
 
find_one_and_updatearray_filters (bsoncxx::array::view_or_value array_filters)
 Set array filters for this operation. More...
 
const stdx::optional< bsoncxx::array::view_or_value > & array_filters () const
 Get array filters for this operation. More...
 

Detailed Description

Class representing the optional arguments to a MongoDB find_and_modify update operation.

Member Function Documentation

◆ array_filters() [1/2]

find_one_and_update& mongocxx::options::find_one_and_update::array_filters ( bsoncxx::array::view_or_value  array_filters)

Set array filters for this operation.

Parameters
array_filtersArray representing filters determining which array elements to modify.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.
See also
https://docs.mongodb.com/manual/reference/command/findAndModify/

◆ array_filters() [2/2]

const stdx::optional<bsoncxx::array::view_or_value>& mongocxx::options::find_one_and_update::array_filters ( ) const

Get array filters for this operation.

Returns
The current array filters.
See also
https://docs.mongodb.com/manual/reference/command/findAndModify/

◆ bypass_document_validation() [1/2]

find_one_and_update& mongocxx::options::find_one_and_update::bypass_document_validation ( bool  bypass_document_validation)

Whether or not to bypass document validation for this operation.

Note
On servers >= 3.2, the server applies validation by default. On servers < 3.2, this option is ignored.
Parameters
bypass_document_validationWhether or not to bypass document validation.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.
See also
https://docs.mongodb.com/master/reference/command/findAndModify/

◆ bypass_document_validation() [2/2]

const stdx::optional<bool>& mongocxx::options::find_one_and_update::bypass_document_validation ( ) const

The current setting for bypassing document validation.

Returns
the current bypass document validation setting.
See also
https://docs.mongodb.com/master/reference/command/findAndModify/

◆ collation() [1/2]

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

Sets the collation for this operation.

Parameters
collationThe new collation.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.
See also
https://docs.mongodb.com/master/reference/command/findAndModify/

◆ collation() [2/2]

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

Retrieves the current collation for this operation.

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

◆ max_time() [1/2]

find_one_and_update& mongocxx::options::find_one_and_update::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).
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.
See also
https://docs.mongodb.com/master/reference/command/findAndModify/

◆ max_time() [2/2]

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

The current max_time setting.

Returns
the current max allowed running time (in milliseconds).
See also
https://docs.mongodb.com/master/reference/command/findAndModify/

◆ projection() [1/2]

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

Sets a projection, which limits the fields to return.

Parameters
projectionThe projection document.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.
See also
https://docs.mongodb.com/master/reference/command/findAndModify/

◆ projection() [2/2]

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

Gets the current projection for this operation.

Returns
The current projection.
See also
https://docs.mongodb.com/master/reference/command/findAndModify/

◆ return_document() [1/2]

find_one_and_update& mongocxx::options::find_one_and_update::return_document ( return_document  return_document)

Set the desired version of the updated document to return, either the original document, or the updated.

By default, the original document is returned.

Parameters
return_documentVersion of document to return, either original or updated.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.
See also
https://docs.mongodb.com/master/reference/command/findAndModify/
mongocxx::options::return_document

◆ return_document() [2/2]

const stdx::optional<mongocxx::options::return_document>& mongocxx::options::find_one_and_update::return_document ( ) const

Which version of the updated document to return.

Returns
Version of document to return, either original or updated.
See also
https://docs.mongodb.com/master/reference/command/findAndModify/
mongocxx::options::return_document

◆ sort() [1/2]

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

Sets the order by which to search the collection for a matching document.

Warning
This can influence which document the operation modifies if the provided filter selects multiple documents.
Parameters
orderingDocument 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://docs.mongodb.com/master/reference/command/findAndModify/

◆ sort() [2/2]

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

Gets the current sort ordering.

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

◆ upsert() [1/2]

find_one_and_update& mongocxx::options::find_one_and_update::upsert ( bool  upsert)

Sets the upsert flag on the operation.

When true, the operation creates a new document if no document matches the filter. When false, this operation will do nothing if there are no matching documents. The server-side default is false.

Parameters
upsertWhether or not to perform an upsert.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.
See also
https://docs.mongodb.com/master/reference/command/findAndModify/

◆ upsert() [2/2]

const stdx::optional<bool>& mongocxx::options::find_one_and_update::upsert ( ) const

Gets the current upsert setting.

Returns
The current upsert setting.
See also
https://docs.mongodb.com/master/reference/command/findAndModify/

◆ write_concern() [1/2]

find_one_and_update& mongocxx::options::find_one_and_update::write_concern ( mongocxx::write_concern  write_concern)

Sets the write concern for this operation.

Parameters
write_concernObject representing the write concern.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.
See also
https://docs.mongodb.com/master/reference/command/findAndModify/

◆ write_concern() [2/2]

const stdx::optional<mongocxx::write_concern>& mongocxx::options::find_one_and_update::write_concern ( ) const

Gets the current write concern.

Returns
The current write concern.
See also
https://docs.mongodb.com/master/reference/command/findAndModify/

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