Skip to content

Instantly share code, notes, and snippets.

@countnazgul
Last active April 17, 2022 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save countnazgul/24f816607fe7608e58ea to your computer and use it in GitHub Desktop.
Save countnazgul/24f816607fe7608e58ea to your computer and use it in GitHub Desktop.
[Batch update records] #mongo
// 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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment