Details
-
Improvement
-
Resolution: Done
-
Minor - P4
-
None
-
None
-
None
Description
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?
Attachments
Issue Links
- depends on
-
SERVER-3409 WriteResult should indicate number of docs modified (no-ops excluded)
-
- Closed
-
- related to
-
DOCS-5491 getlasterror.n documentation is misleading
-
- Closed
-