Is findAndModify also atomic with an added sort option

Hi everyone!

I have read everywhere that findAndModify() is an atomic operation when used for updating a document. Is this also true if one passes a sort option?
Given that a sort may take some time, how is it enforced that the operation is still atomic, if it is the case? Does it involve a huge lock over the sorted documents or is the validity of the query checked again when opening a document for writing or is there a different mechanism at play?

Thanks in advance!

1 Like