MongoDB C++ Driver
mongocxx-3.0.2
|
Class representing a MongoDB update operation that replaces a single document. More...
#include <replace_one.hpp>
Public Member Functions | |
replace_one (bsoncxx::document::view_or_value filter, bsoncxx::document::view_or_value replacement) | |
Constructs an update operation that will replace a single document matching the filter. More... | |
const bsoncxx::document::view_or_value & | filter () const |
Gets the filter for replacement. More... | |
const bsoncxx::document::view_or_value & | replacement () const |
Gets the replacement document. More... | |
replace_one & | 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 replaces a single document.
mongocxx::model::replace_one::replace_one | ( | bsoncxx::document::view_or_value | filter, |
bsoncxx::document::view_or_value | replacement | ||
) |
Constructs an update operation that will replace a single document matching the filter.
filter | Document representing the criteria for replacement. |
replacement | Document that will serve as the replacement. |
const bsoncxx::document::view_or_value& mongocxx::model::replace_one::filter | ( | ) | const |
Gets the filter for replacement.
const bsoncxx::document::view_or_value& mongocxx::model::replace_one::replacement | ( | ) | const |
Gets the replacement document.
replace_one& mongocxx::model::replace_one::upsert | ( | bool | upsert | ) |
Sets the upsert option.
When upsert is true
, this operation will insert the replacement document as a new document if no existing documents match the filter. When upsert is false
, the replacement operation does nothing if there are no matching documents. By default, upsert is false
.
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::replace_one::upsert | ( | ) | const |
Gets the current value of the upsert option.