Reputation: 1851
I am trying to understand if issuing a mongo.update call will take a write lock immediately, or will it first take a read lock to get the data and only then will take a write lock to modify the data.
Also i am trying to understand what will be the behaviour when using other mongo functions like findOneAndUpdate or findAndModify
Upvotes: 1
Views: 154
Reputation: 21766
According to the documentation, when modifying a single document, both findAndModify
and the update
method atomically update the document. This implies that a write lock is taken out immediately. If you want to atomically update multiple records you have to use the $isolated
operator.
Upvotes: 1