Suppose there is a document structure as shown below:
{_id:"session-01", status:"free"}
And there are two parallel operations that perform the findAndModify operation below: db.collection.findAndModify({query:{status:"free"}, update:{status:"occupied"}, new:true})
What I want to achieve is that only one operation can get "free" and lock on it, so the other operation must be zero. Is this what findAndModify does?
mongodb mongodb-query
Agung pratama
source share