Report both the number of documents ("n") which were matched and have the expected updated values, and the number of docs which were actually changed with a write to the database ("nDocsModified").
Expected:
> db.rb.save({_id:3, a:[1,2]}) Updated 1 existing record(s) in 6ms Update WriteResult({ "ok" : 1, "nDocsModified" : 1, "n" : 1 ... }) // No-op doesn't require modifying the document > db.rb.save({_id:3, a:[1,2]}) Updated 1 existing record(s) in 2ms Update WriteResult({ "ok" : 1, "nDocsModified" : 0, "n" : 1 ... })
Note: These changes only apply to the new write commands, not the old wire protocol updates. This means you must be using a new driver/client to see this field in the WriteResults.
Old Description
db.foo.save(
)
db.foo.update(
, {$addToSet:
{ n: 'foo' }} )
db.getPrevError();
{ "err" : null, "updatedExisting" : true, "n" : 1, "nPrev" : 1, "ok" : 1 }updatedExisting should be false in this case, since the document was not, in fact, updated.
- is depended on by
-
SERVER-18639 Expose number of modified documents in getLastError output
- Closed
- is duplicated by
-
SERVER-8422 Log/getLastError/profile output reports nupdated:1 even if no change
- Closed
-
SERVER-2769 Provide a way to find out if $addToSet caused a change to the list
- Closed
- related to
-
SERVER-9038 New write operation method for insert, update, remove
- Closed
-
SERVER-1501 Enhance getlasterror to include indication of when $unset, $pull or $pullAll modifier operations do not actually remove data
- Closed