Monday, 15 February 2010

locking - Mongodb findAndModify atomicity -



locking - Mongodb findAndModify atomicity -

i want know how reference returned document attributes find , utilize within modify. e.x. :

var totalnoofsubjects = 5; db.people.findandmodify( { query: { name: "tom", state: "active", rating: { $gt: 10 } }, sort: { rating: 1 }, update: { $set: { average: <reference score value returned find>/totalnoofsubjects} } } );

my understanding findandmodify locks document, hence want perform update in modify using attributes found in find. create operation atomic.

i wondering if supported mongo.

no, cannot refer values in found document during update portion of findandmodify. it's same update in respect.

as such, cannot atomically need first fetch document , craft update or findandmondify contain value computed fetched doc.

see https://jira.mongodb.org/browse/server-458 1 way may addressed in future.

mongodb locking atomic findandmodify

No comments:

Post a Comment