I am tired I read all return value from callback but not any one please help me.
I have a database and I do aggregation and I want take a total value and use the return value in another function
function daly(x, callback) {
tarry = [];
sale.aggregate([{
$match: {
salepro: "mouse"
}
}, {
$group: {
_id: "id",
totalAmount: {
$sum: "$saleprice"
}
}
}], function(err, rs) {
tarry.push(rs);
console.log(tarry);
return callback(tarry);
})
console.log(tarry);
}