【发布时间】:2019-08-22 09:59:55
【问题描述】:
我使用 group 和 match 编写解析聚合管道,但它不起作用 它在 mongo compass 中工作,但在解析服务器中被拒绝,请建议正确的语法
test(callback) {
let Employee = Parse.Object.extend("Employee");
var query = new Parse.Query(Employee);
var pipeline = [
[
{
'match': {
'isActive': true
}
}, {
'group': {
'objectId': null,
'total': {
'$sum': '$defaultAccNum'
}
}
}
]
]
query.aggregate(pipeline, { useMasterKey: true })
.then(function (results) {
debugger
// results contains sum of score field and stores it in results[0].total
}).catch(function (error) {
// There was an error.
});
}
}
【问题讨论】:
-
你能分享错误堆栈吗?
-
localhost:8100/vendor.js:157457:19 在 ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (localhost:8100/polyfills.js:2733:26) 在 Object.onInvoke (localhost:8100/vendor.js:58236:33) 在ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (localhost:8100/polyfills.js:2732:32) 在 Zone.push../node_modules/zone.js/dist/zone.js.Zone.run跨度>
-
错误信息是什么?