restheart icon indicating copy to clipboard operation
restheart copied to clipboard

bulk post with writeMode=update does not replace the matching documents but just updates the passed properties

Open ujibang opened this issue 7 months ago • 0 comments

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.

ujibang avatar Jan 25 '24 08:01 ujibang