Tuesday, 2 May 2017

How to return mongoose result from the aggregate method?

I want to pressing form pointPerMonth to item.point, why i cannot pressing data

utils.pointPerMonth(item._id, function (point) {
   item.point = point;
});

exports.pointPerMonth = function(_id, callback) {
    BillSell.aggregate([
        {
            $group: {
                _id: null,
                total: {
                    $sum: '$point'
                }
            }
        }
    ])
    .exec(function(err, output) {
        callback(output);
    });
}



via K PANCHON

No comments:

Post a Comment