Skip to content

Instantly share code, notes, and snippets.

@cranic
Created February 4, 2014 18:49
Show Gist options
  • Select an option

  • Save cranic/8809833 to your computer and use it in GitHub Desktop.

Select an option

Save cranic/8809833 to your computer and use it in GitHub Desktop.
async.parallel([
function(callback){
db.order_book.aggregate(
[
{ $match: {currency: task.params.currency, pricing: task.params.pricing}},
{ $group: {_id: "$price", amount: {$sum: "$amount"}}},
{ $sort: {_id: -1}}
], callback
);
},
function(callback){
db.order_book.aggregate(
[
{ $match: {currency: task.params.pricing, pricing: task.params.currency}},
{ $group: {_id: "$price", amount: {$sum: "$amount"}}},
{ $sort: {_id: 1}}
], callback
);
}
],
function(err,results){
console.log(results[0]);
console.log(results[1]);
update_task(task,function(err,res){
if(err)
console.log(err);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment