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

Class representing a MongoDB update operation that modifies multiple documents. More...

#include <update_many.hpp>

Public Member Functions

 update_many (bsoncxx::document::view_or_value filter, bsoncxx::document::view_or_value update)
 Constructs an update operation that will modify all documents matching the filter. More...
 
const bsoncxx::document::view_or_valuefilter () const
 Gets the filter. More...
 
const bsoncxx::document::view_or_valueupdate () const
 Gets the update document. More...
 
update_manycollation (bsoncxx::document::view_or_value collation)
 Sets the collation for this update operation. More...
 
const stdx::optional< bsoncxx::document::view_or_value > & collation () const
 Gets the collation option for this update operation. More...
 
update_manyupsert (bool upsert)
 Sets the upsert option. More...
 
const stdx::optional< bool > & upsert () const
 Gets the current value of the upsert option. More...
 
update_manyarray_filters (bsoncxx::array::view_or_value array_filters)
 Set array filters for this update operation. More...
 
const stdx::optional< bsoncxx::array::view_or_value > & array_filters () const
 Get array filters for this operation. More...
 

Detailed Description

Class representing a MongoDB update operation that modifies multiple documents.

Constructor & Destructor Documentation

◆ update_many()

mongocxx::model::update_many::update_many ( bsoncxx::document::view_or_value  filter,
bsoncxx::document::view_or_value  update 
)

Constructs an update operation that will modify all documents matching the filter.

Parameters
filterDocument representing the criteria for applying the update.
updateDocument representing the modifications to be applied to matching documents.

Member Function Documentation

◆ array_filters() [1/2]

update_many& mongocxx::model::update_many::array_filters ( bsoncxx::array::view_or_value  array_filters)

Set array filters for this update operation.

Parameters
array_filtersArray representing filters determining which array elements to modify.
See also
https://docs.mongodb.com/manual/reference/command/update/

◆ array_filters() [2/2]

const stdx::optional<bsoncxx::array::view_or_value>& mongocxx::model::update_many::array_filters ( ) const

Get array filters for this operation.

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

◆ collation() [1/2]

update_many& mongocxx::model::update_many::collation ( bsoncxx::document::view_or_value  collation)

Sets the collation for this update operation.

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

◆ collation() [2/2]

const stdx::optional<bsoncxx::document::view_or_value>& mongocxx::model::update_many::collation ( ) const

Gets the collation option for this update operation.

Returns
The optional value of the collation option.
See also
https://docs.mongodb.com/master/reference/collation/

◆ filter()

const bsoncxx::document::view_or_value& mongocxx::model::update_many::filter ( ) const

Gets the filter.

Returns
The filter to be used for the update operation.

◆ update()

const bsoncxx::document::view_or_value& mongocxx::model::update_many::update ( ) const

Gets the update document.

Returns
The modifications to be applied as part of the update.

◆ upsert() [1/2]

update_many& mongocxx::model::update_many::upsert ( bool  upsert)

Sets the upsert option.

When upsert is false, update does nothing when no documents match the filter. However, by specifying upsert as true, this operation either updates matching documents or inserts a new document using the update specification if no matching document exists. By default, upsert is unset by the driver, and the server-side default, false, is used.

Parameters
upsertIf set to true, creates a new document when no document matches the query criteria. The server side default is false, which does not insert a new document if a match is not found.

◆ upsert() [2/2]

const stdx::optional<bool>& mongocxx::model::update_many::upsert ( ) const

Gets the current value of the upsert option.

Returns
The optional value of the upsert option.

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