MongoDB sometimes return a lastErrorObject
- and as far as I can read this is its schema:
{
updatedExisting: <boolean>,
upserted: <boolean>,
n: <num>,
connectionId: <num>,
err: <string>,
ok: <num>
}
But the only place on the mongodb.org website I can find any reference to this object is buried in the findAndModify API documentation.
But nowhere can I find any explanation of the different properties of the object. I can make educated guesses, but even what I can make out from the documentation seems to contradict it self. Like for instance upserted
, which according to findAndModify should be a boolean, but apparently also can be an ObjectId
.
And what is ok
? It seems to be 1
most of the time - but it's not a boolean, so can it be 2
and what does that mean?
Even though some of the properties might be pretty self-explanatory, please write an explanation for each in your answer so it's 100% documented for everybody. Or if I just missed it (it happens), feel free to link to the documentation where this is explained ;)
I think you have all posible return values in this page
But I agree with you. Sometimes MongoDB documentation is quite messy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With