[英]How to use mongo db aggregate function in meteor with angular js?
I want know how to use mongo db aggregate function in meteor with angular. 我想知道如何在带角度的流星中使用mongo db聚合函数。
I added the below packages: 我添加了以下软件包:
meteor add meteorhacks:aggregate
meteor add monbro:mongodb-mapreduce-aggregation
In angular service, I wrote the code like this, 在角度服务中,我这样编写代码,
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"}}}]);
});
};
When i run this code , giving the below exception. 当我运行此代码时,给出以下异常。
TypeError: Products.aggregate is not a function
Do i need to do any additional setup? 我是否需要进行其他设置? Do i need to add plugin in app.js?
我需要在app.js中添加插件吗?
It works only server side. 它仅在服务器端起作用。 write server side method to calculate aggregate in meteor.
编写服务器端方法以计算流星总数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.