The new commands for insert, delete and update currently only return the total number of documents deleted and modified.
This significantly reduces the utility of batching since it is impossible for the user to now what actually happened for each update and delete that leads to users falling back to not batching the updates and deletes which negates the purpose of the command in the first place.
Simply adding an array to the output for the delete and update containing the details for each operation similar to the following will allow users to use the batching commands: (cribbing from the docs)
db.runCommand( { delete: "orders", deletes: [ { q: { status: "D" }, limit: 0 }, { q: { cust_num: 99999, item: "abc123", status: "A" }, limit: 1 } ], ordered: false, writeConcern: { w: 1 } } ) { "ok" : 1, "n" : 21 "deletes" : [ 21, 0 ] }
In this example we see that the single delete did not actually delete any documents. It is easy to imagine a situation where that may be important.
db.runCommand( { update: "users", updates: [ { q: { status: "P" }, u: { $set: { status: "D" } }, multi: true }, { q: { _id: 5 }, u: { _id: 5, name: "abc123", status: "A" }, upsert: true } ], ordered: false, writeConcern: { w: 1 } } ) { "ok" : 1, "nDocsModified" : 10, "n" : 11, "upserted" : [ { "index" : 1, "_id" : 5 } ] "modified" : [ 10, 1 ] }
In this case we could have already determined that the first update had modified 10 documents since the second happened to be an upsert. In general this will not be the case.
- is related to
-
SERVER-13054 Statistics from write commands
- Closed
-
SERVER-33121 Add updated/deleted _id's to response object of updateMany and deleteMany
- Closed
- related to
-
SERVER-3920 Get object IDs for mutated objects after an update
- Backlog