How can I effectively use the mongo db aggregate function in meteor with angular?
I have included the following packages:
meteor add meteorhacks:aggregate
meteor add monbro:mongodb-mapreduce-aggregation
In my angular service, I have written the code as follows:
function getProductDetailsForCompare (skus) {
return $meteor.collection( function() {
return Products.aggregate([{ $match: {$or: [{"sku":"777160-001"},{"sku":"777161-001"},{"sku":"728350-B21"}]}}, {$group : {_id : "$sku", price : {$min : "$price"}}}]);
});
};
However, when running this code, I encounter the following exception:
TypeError: Products.aggregate is not a function
Are there additional setup steps required? Do I need to include a plugin in app.js?