我想创建一个仪表板,我将在其中显示简单的统计信息,例如用户数、评论数等。
我正在使用类似的东西来计算我的收藏
User.count(function(err, num){
if (err)
userCount=-1;
else
userCount = num;
Comment.count(function(err, num){
if (err)
commentCount=-1;
else
commentCount = num;
SomethingElse.count(...)
})
})
我认为这有点难看。有没有其他方法可以在不嵌套 4 个计数的情况下做到这一点?