我想用mongoose的count方法查询stations集合里各个部门的数量,push进一个数组然后返回给Echarts,可是响应的却是空的数组,请教各位大神应该怎么解决?
router.get('/chart', function (req, res, next) {
let depts = ['部门1', '部门2', '部门3', '部门4', '部门5',
'部门6', '部门7', '部门8'];
let department = [];
for(let x in depts){
stations.count({"dept": depts[x]}).exec(function (err, counts) {
department.push(counts);
});
}
res.json(department);
});
慕数据1385771
慕数据1385771
慕数据1385771
慕数据1385771
PIPIONE
互换的青春
相关分类