我知道这里已经问了几个问题,但是没有人给我正确的答案。所以基本上我有这样的架构
const cashFlowSchema = new Schema({
date: { type: Date, default: Date.now },
type: { type: String, required: true },
category: { type: String, required: true },
amount: { type: Number, required: true },
description: String
});
然后我尝试用sum
来创建金额为aggregate
的get CashFlow.aggregate([{
$group: {
_id: null,
balance: { $sum: "$amount" }
}
}], function(err, result) {
if (err) {
console.log(err);
return;
}
console.log(result);
});
[ { _id: null, balance: 0 } ]
并给出这样的结果
3.4
但是,如果我尝试使用Robo3T(以前称为Robomongo),它将为我提供正确的答案。我使用的是mongodb版本debug
。谢谢你。
更新
我找到了答案,所以这是我的愚蠢错误。在猫鼬中启用 private void txtBoxPassword_TextChanged(object sender, EventArgs e)
{
//password view protection//
txtBoxPassword.UseSystemPasswordChar = true;
}
模式后,表明我与收藏夹的连接错误。修复后,我得到正确的结果。我将很快删除此问题,谢谢所有。