MongoDB C++ Driver
mongocxx-3.0.1
|
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_value & | filter () const |
Gets the filter. More... | |
const bsoncxx::document::view_or_value & | update () const |
Gets the update document. More... | |
update_many & | upsert (bool upsert) |
Sets the upsert option. More... | |
const stdx::optional< bool > & | upsert () const |
Gets the current value of the upsert option. More... | |
Class representing a MongoDB update operation that modifies multiple documents.
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.
filter | Document representing the criteria for applying the update. |
update | Document representing the modifications to be applied to matching documents. |
const bsoncxx::document::view_or_value& mongocxx::model::update_many::filter | ( | ) | const |
Gets the filter.
const bsoncxx::document::view_or_value& mongocxx::model::update_many::update | ( | ) | const |
Gets the update document.
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.
upsert | If 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. |
const stdx::optional<bool>& mongocxx::model::update_many::upsert | ( | ) | const |
Gets the current value of the upsert option.