我在 Angular2-Meteor 应用程序中使用“meteorhacks”的“聚合”。
我已经添加了这个包并且它工作得很好,但问题是我收到了一个警告:
Property 'aggregate' does not exist on type 'Collection< Attendance>'.
我有一组出勤率,我正在使用汇总...
我和我的收藏常量是:
export const Attendances = new MongoObservable.Collection<Attendance>("attendances");
所以我尝试通过管道使用聚合,我们将聚合数组存储在一个变量中,而不是在聚合中使用该变量。
我的聚合代码如下所示:
let totalBonus = Attendances.collection.aggregate(['my queries and $match']);
那么如何在没有警告的情况下使用聚合呢?
我已经尝试在聚合之前删除“集合”,但它不起作用!
请帮助我警告,在此先感谢...
请不要拒绝我的问题... :)
最佳答案
将其添加到使用该函数的文件中:
/// <reference path="..path../declarations.d.ts" />
并将其放入 declarations.d.ts 文件中:
declare module Mongo {
interface Collection {
aggregate(args:any, filter:any): Array<any>;
}
关于angular - 如何在 Angular2-Meteor 应用程序中使用来自 "meteorhacks"的聚合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41610464/