restheart
restheart copied to clipboard
bulk post with writeMode=update does not replace the matching documents but just updates the passed properties
Describe the bug
The mongodb rest API bulk post, i.e. does not replace the whole matching documents. Instead it just updates the passed properties of matching documents
Create 2 docs
POST /coll?wm=upsert
[ { "_id": 1, "a": 1 }, { "_id": 2, "a": 2 } ]
Now execute the bulk update:
POST /coll?wm=update
[ { "_id": 1, "b": 1 }, { "_id": 2, "b": 2 } ]
The resulting documents will have both a
and b
properties. They should only have the b
property.
This is due to DbUtils.bulkWriteDocuments()
uses UpdateOneModel
.
It should use ReplaceOneModel
instead.