-
Type:
Improvement
-
Resolution: Done
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Write Ops
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
This came up in DOCS-5491: getLastError.n represents the number of matched documents, but it doesn't return the number of modified documents. For example:
> db.foo.insert({x:1, y:2})
WriteResult({ "nInserted" : 1 })
> db.foo.update({x:1}, {$set: {y:2}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 0 })
> db.runCommand( { getLastError: 1, w: 1 } )
{
"connectionId" : 22,
"updatedExisting" : true,
"n" : 1,
"syncMillis" : 0,
"writtenTo" : null,
"err" : null,
"ok" : 1
}
> db.foo.update({x:3}, {$set:{y:3}}, {upsert:true})
WriteResult({
"nMatched" : 0,
"nUpserted" : 1,
"nModified" : 0,
"_id" : ObjectId("555f835e3bd3ad1bd7a14b9f")
})
> db.runCommand( { getLastError: 1, w: 1 } )
{
"connectionId" : 22,
"n" : 0,
"syncMillis" : 0,
"writtenTo" : null,
"err" : null,
"ok" : 1
}
Can the number of modified documents be added to the output of getLastError?
- depends on
-
SERVER-3409 WriteResult should indicate number of docs modified (no-ops excluded)
-
- Closed
-