Assume there is document's structure like below:
{_id:"session-01", status:"free"}
And there are 2 concurrent operations that perform the findAndModify
operation below:
db.collection.findAndModify({query:{status:"free"}, update:{status:"occupied"}, new:true})
What I want to achieve is only one operation can get the "free" one, and perform lock on it, so the other operation must be getting null. Is that what the findAndModify does?