我试图让按学校分组的学生和每所学校的学生人数如此:
return Student.find({ where: {school: schoolIdArray}, groupBy: [ 'school' ], sum: [ 'totalAmt' ] })
.exec(function(error, response) {
console.log(response);
});
我一直得到以下内容:
[ { school: '57424c8908d4af812c77a77e', totalAmt: 0 }, etc. ]
为什么学校的所有学生都是0?
我在下面阅读了以下内容:
Select Group by count and distinct count in same mongodb query
https://github.com/balderdashy/sails-mongo/blob/master/lib/query/aggregate.js#L43
https://github.com/balderdashy/waterline-docs/blob/master/queries/query-language.md
我能为此做些什么吗?