MongoDB C++ Driver mongocxx-4.0.0
|
#include <mongocxx/v_noabi/mongocxx/model/replace_one.hpp>
Class representing a MongoDB update operation that replaces a single document.
Public Member Functions | |
replace_one (bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value replacement) | |
Constructs an update operation that will replace a single document matching the filter. | |
const bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > & | collation () const |
Gets the collation option for this replacement operation. | |
replace_one & | collation (bsoncxx::v_noabi::document::view_or_value collation) |
Sets the collation for this replacement operation. | |
const bsoncxx::v_noabi::document::view_or_value & | filter () const |
Gets the filter for replacement. | |
const bsoncxx::v_noabi::stdx::optional< mongocxx::v_noabi::hint > & | hint () const |
Gets the current hint. | |
replace_one & | hint (mongocxx::v_noabi::hint index_hint) |
Sets the index to use for this operation. | |
const bsoncxx::v_noabi::document::view_or_value & | replacement () const |
Gets the replacement document. | |
const bsoncxx::v_noabi::stdx::optional< bool > & | upsert () const |
Gets the current value of the upsert option. | |
replace_one & | upsert (bool upsert) |
Sets the upsert option. | |
mongocxx::v_noabi::model::replace_one::replace_one | ( | bsoncxx::v_noabi::document::view_or_value | filter, |
bsoncxx::v_noabi::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::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > & mongocxx::v_noabi::model::replace_one::collation | ( | ) | const |
Gets the collation option for this replacement operation.
replace_one & mongocxx::v_noabi::model::replace_one::collation | ( | bsoncxx::v_noabi::document::view_or_value | collation | ) |
Sets the collation for this replacement operation.
collation | The new collation. |
const bsoncxx::v_noabi::document::view_or_value & mongocxx::v_noabi::model::replace_one::filter | ( | ) | const |
Gets the filter for replacement.
const bsoncxx::v_noabi::stdx::optional< mongocxx::v_noabi::hint > & mongocxx::v_noabi::model::replace_one::hint | ( | ) | const |
Gets the current hint.
replace_one & mongocxx::v_noabi::model::replace_one::hint | ( | mongocxx::v_noabi::hint | index_hint | ) |
Sets the index to use for this operation.
index_hint | Object representing the index to use. |
const bsoncxx::v_noabi::document::view_or_value & mongocxx::v_noabi::model::replace_one::replacement | ( | ) | const |
Gets the replacement document.
const bsoncxx::v_noabi::stdx::optional< bool > & mongocxx::v_noabi::model::replace_one::upsert | ( | ) | const |
Gets the current value of the upsert option.
replace_one & mongocxx::v_noabi::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. |