Closed ujibang closed 2 months ago
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.
a
b
This is due to DbUtils.bulkWriteDocuments() uses UpdateOneModel.
DbUtils.bulkWriteDocuments()
UpdateOneModel
It should use ReplaceOneModel instead.
ReplaceOneModel
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
Now execute the bulk update:
The resulting documents will have both
a
andb
properties. They should only have theb
property.This is due to
DbUtils.bulkWriteDocuments()
usesUpdateOneModel
.It should use
ReplaceOneModel
instead.