I have a code similar to
db.myColletion.update({'_id':ObjectId("...")}, {'$set': {'state': 'CA'}})
Is above an atomic operation?
Do I need to use findAndModify even on single document for atomicity??
Yes, all write operations with MongoDB are atomic at the level of a single document.
The key difference between update
and findAnyModify
is that the latter also provides you with the original or updated document.
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