Skip to content Skip to sidebar Skip to footer

Mongodb Findandmodify - Update Data

I have this already in the MongoDB collections. { '_id' : ObjectId('4e677efce88c7f0718000000'), 'ptbn' : 'indl000000001', 'tbucode' : '5649', 'district' : 'west', 'dcode' : '11004

Solution 1:

You don't actually need findAndModify for this. A simple update() will do the trick.

db.tc_basic.update({'_id':ObjectId("...")}, {'$set': {'state': 'goa', 'district': 'north'}})

For more details on what you can do with update() see: http://www.mongodb.org/display/DOCS/Updating

Post a Comment for "Mongodb Findandmodify - Update Data"