Meteor/Mongo 无法从 aggregate/pipeline 加载数据

Meteor/Mongo Failure to load data from aggregate/pipeline

服务器控制台错误:UnhandledPromiseRejectionWarning:RangeError:超出最大调用堆栈大小

流星 1.8.1

项目在 1.6.x、MongoDB 3.2.x

时运行良好

mlab 将我推到 mongo 3.6.x 现在我的一些图表 (chart.js) 和 tables (aslagle:reactive-table) 不工作。

这两个都是通过 aggregate/pipeline(下面的示例)生成的。

长话短说,我已经忽视这个项目好几个月了,现在才重新开始,运行 进入这个问题,并尝试更新到 1.8.1。我在 mongo 4.0.6

图表和 table 仍然无法正常工作,我认为这是因为我缺少对聚合 and/or 管道中 syntax/structure 的一些更新。我在这里很可能是错的,因为我生疏了,不是贸易开发人员,而且如上所述几个月没碰过这个。

这是一个失败的aggregate/pipeline,用于绘制折线图(Chart.js):

pointTrendsSprt: function(uid, sp){
    var pipeline = [
                        { $match: {"userId": uid, "sport":sp, "slate": {$exists: true} } },
                        { $project: {slate:1, sport:1, pointsWon:1, createdAt:1} },
                        { $group: {
                                    _id: "$slate",
                                    sport: {"$addToSet": "$sport"},
                                    pointsWon: {"$sum": "$pointsWon"},
                                    createdAt: {"$max": "$createdAt"}
                                  } 
                        },
                        { $sort: { "createdAt":1 } }
                    ];

    return Results.aggregate(pipeline);
},

这是另一个用在 aslagle:reactive-table:

allXteam: function(uid){
    var pipeline = [
                        { $match: {"userId": uid, "win": "true"} },
                        { $project: {team:1, match:1, play:1, Count: "$count"} },
                        { $group: 
                            {_id: "$team", 
                            play: {"$addToSet": "$play"},
                            count:{$sum:1}} 
                        }
                    ];

    return Picks.aggregate( pipeline );

},

这两个都在服务器文件夹的 methods.js 文件中。我在客户端 js 文件上使用 Meteor.call 来设置图表和 tables 从中提取的会话变量。

如前所述,我想我需要在我的 aggregations/pipelines 中修复一些东西,但我尝试添加“光标”和“解释”,但在那个假设中要么做错了,要么做错了。

任何 suggestions/guidance 将不胜感激。

我发现 this solution 有效:

Collection.rawCollection().聚合().toArray()

这是我最后的重构(尽管我将不得不研究 'Meteor.wrapAsync' 形式:

allXteam: async function(uid){
    var pipeline = [
                        { $match: {"userId": uid, "win": "true"} },
                        { $project: {team:1, match:1, play:1, Count: "$count"} },
                        { $group: 
                            {_id: "$team", 
                            play: {"$addToSet": "$play"},
                            count:{$sum:1}} 
                        }
                    ];

    const aXt = await Picks.rawCollection().aggregate( pipeline ).toArray();

    return aXt;