MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
mongocxx::model::update_many Class Reference

#include <mongocxx/v_noabi/mongocxx/model/update_many.hpp>

Description

A MongoDB update operation that modifies multiple documents.

Public Member Functions

 update_many (bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value update)
 Constructs an update operation that will modify all documents matching the filter.
 update_many (bsoncxx::v_noabi::document::view_or_value filter, pipeline const &update)
 Constructs an update operation that will modify all documents matching the filter.
 update_many (bsoncxx::v_noabi::document::view_or_value filter, std::initializer_list< _empty_doc_tag > update)
 Constructs an update operation that will modify all documents matching the filter.
 update_many (v1::bulk_write::update_many op)
 Construct with the mongocxx::v1 equivalent.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::array::view_or_value > const & array_filters () const
 Get array filters for this operation.
update_manyarray_filters (bsoncxx::v_noabi::array::view_or_value array_filters)
 Set array filters for this update operation.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & collation () const
 Gets the collation option for this update operation.
update_manycollation (bsoncxx::v_noabi::document::view_or_value collation)
 Sets the collation for this update operation.
bsoncxx::v_noabi::document::view_or_value const & filter () const
 Gets the filter.
bsoncxx::v_noabi::stdx::optional< v_noabi::hint > const & hint () const
 Gets the current hint.
update_manyhint (v_noabi::hint index_hint)
 Sets the index to use for this operation.
 operator v1::bulk_write::update_many () const
 Convert to the mongocxx::v1 equivalent.
bsoncxx::v_noabi::document::view_or_value const & update () const
 Gets the update document.
bsoncxx::v_noabi::stdx::optional< bool > const & upsert () const
 Gets the current value of the upsert option.
update_manyupsert (bool upsert)
 Sets the upsert option.

Constructor & Destructor Documentation

◆ update_many() [1/4]

◆ update_many() [2/4]

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.

◆ update_many() [3/4]

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

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

◆ update_many() [4/4]

mongocxx::v_noabi::model::update_many::update_many ( bsoncxx::v_noabi::document::view_or_value filter,
std::initializer_list< _empty_doc_tag > update )
inline

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

Parameters
filterDocument representing the criteria for applying the update.
updateSupports the empty update {}.

Member Function Documentation

◆ array_filters() [1/2]

◆ array_filters() [2/2]

Set array filters for this update operation.

Parameters
array_filtersArray representing filters determining which array elements to modify.
See also

◆ collation() [1/2]

Gets the collation option for this update operation.

Returns
The optional value of the collation option.
See also

◆ collation() [2/2]

Sets the collation for this update operation.

Parameters
collationThe new collation.
See also

◆ filter()

Gets the filter.

Returns
The filter to be used for the update operation.

◆ hint() [1/2]

Gets the current hint.

Returns
The current hint, if one is set.

◆ hint() [2/2]

Sets the index to use for this operation.

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.
Returns
A reference to the object on which this member function is being called. This facilitates method chaining.

◆ operator v1::bulk_write::update_many()

mongocxx::v_noabi::model::update_many::operator v1::bulk_write::update_many ( ) const
inlineexplicit

Convert to the mongocxx::v1 equivalent.

◆ update()

Gets the update document.

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

◆ upsert() [1/2]

Gets the current value of the upsert option.

Returns
The optional value of the upsert option.

◆ upsert() [2/2]

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.

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