-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: 0.2.0
-
Component/s: Implementation
-
None
-
None
-
None
-
None
-
None
-
None
-
None
As per mongodb documentation, updating entire document is possible as:
update.js
db.people.update(
{ name: "Andy" },
{
name: "Andy",
rating: 1,
score: 1
},
{ upsert: true }
)
One need provide update operators such as $set only when updating sub-document. The same should be achieveable with the C++11 driver as:
update.cxx
{
// @begin: cpp-update-top-level-fields
bsoncxx::builder::stream::document filter_builder, update_builder;
filter_builder << "name"
<< "Juni";
update_builder << "cuisine"
<< "American (New)";
db["restaurants"].update_one(filter_builder.view(), update_builder.view());
// @end: cpp-update-top-level-fields
}
However, executing the above code leads to
terminate called after throwing an instance of
stderr
'mongocxx::v0::bulk_write_exception' what(): Cannot do an empty bulk write: mongoc command_invalid_arg error
- depends on
-
CDRIVER-1060 Bulk write updates require $set, but regular updates do not
-
- Closed
-