Atomicity between query and update part of updateOne

both the updateOne and updateMany take in the first argument as the query filter.


  1. No transactions

For updateOne:

Thread1 invokes updateOne and suppose the query filter (first argument of updateOne) returns a document1 for update

The question:

Is that document1 now locked so no other thread can update that before thread1 can finish with the updates. This implies that document1 does not change from when the query filter (updateOne’s first argument) ran and returned to the time when the actual update occurs. So thread1 operates on document unchanged by any other thread from when it first retrieved document1 due to it matching the query filter to the time that it updates it as part of the updateOne operation.

Further Question:

Is it any different when there it is part of a transaction?