MongoDB bulk update and insert

Just a note to myself (kinda) how to perform bulk update in MongoDB. (it took me some time to figure it out) // OrderId = [1,2,3,4,5,6] BulkUpdate(OrderId, function() { console.log('done'); }); function BulkUpdate(OrderId, callback) { Model.update( { orderid : { $in: OrderId } }, { $set: { status: 'complete' } }, { multi : true}).exec(callback); } Update (2014-09-16) And here is the bulk insert code example: ...

September 15, 2014 · 1 min · 91 words