Why does getLastError
show that no docs were updated when it was?
> db.contacts.find()
{ "_id" : ObjectId("509b60e7c546b6dc73f57877"), "name" : "mike" }
> db.contacts.update({}, {name: 'peter'})
> db.runCommand({getLastError: 1})
{ "n" : 0, "connectionId" : 3188, "err" : null, "ok" : 1 }
> db.contacts.find()
{ "_id" : ObjectId("509b60e7c546b6dc73f57877"), "name" : "peter" }
getLastError
is returning n: 0
, even though a document was clearly updated. It's also missing the updatedExisting
field. I'm running this remotely on a sample MongoHQ database.
Run against my local MongoDB instance, getLastError
correctly returns this:
> db.runCommand({getLastError: 1})
{
"updatedExisting" : true,
"n" : 1,
"connectionId" : 1,
"err" : null,
"ok" : 1
}