This commit is contained in:
2021-07-27 19:21:05 -05:00
parent f84c170832
commit 2db1144834

View File

@@ -62,7 +62,8 @@ router.get("/resumen_compras", checkAuth, async (req, res) => {
compras_ = await Compras.aggregate([ compras_ = await Compras.aggregate([
{$match: { $and: [{ user:req.userData._id}, filtros] }}, {$match: { $and: [{ user:req.userData._id}, filtros] }},
{$group:{_id:{categoria:"$categoria"},total:{$sum:"$valor"}}} {$group:{_id:{categoria:"$categoria"},total:{$sum:"$valor"}}}
]); ]).sort({total:"desc"});
compras_.forEach(element => { compras_.forEach(element => {
//console.log(element.total) //console.log(element.total)
labels.push(element._id.categoria) labels.push(element._id.categoria)