我在填充"Main"集合时遇到了问题,分组工作得很好,但我真的不知道如何填充,甚至在聚合后找到.find.我相信我在这里做模特铸造:
Main.aggregate([
{$match : query},
{
$group:{
_id: queryGroupBy,
activated: {$sum: '$activated'},
componentTitle: {$first:'$componentTitle'},
titlePrefix: {$first:'$titlePrefix'},
operator_name: {$first:'$operator_name'}
}
},
{
$project:{
_id: '$_id',
summation: '$activated',
componentTitle: '$componentTitle',
titlePrefix: '$titlePrefix',
operator_name: '$operator_name'
}
}],
function(err,results) {
if (err) throw err;
result = results.map(function(doc) {
doc._id = doc._id,
doc.activated = doc.activated,
doc.componentTitle = doc.componentTitle,
doc.titlePrefix = doc.titlePrefix,
doc.operator_name = doc.operator_name,
doc.fssStatusFDD = "",
doc.dateUpdated = "",
delete doc._id;
delete doc.summation;
var _main = new Main();
_main = doc;
console.log('test3');
return _main …Run Code Online (Sandbox Code Playgroud)