如何在猫鼬中使用分组

时间:2019-01-19 19:08:12

标签: node.js mongoose

我想在我的猫鼬查询中使用分组依据,这是我到目前为止使用猫鼬进行的尝试

const sumByNetType= await mongoose.connection.db.collection(f)
.aggregate([{$match:{"network_type":n}},{$group:{_id:"$network_type",'total': { '$sum': { '$toInt': '$cost' } }}}])

其中n是包含我的网络类型的变量,f是包含集合名称的变量,但是每当我console.log记录可变的sumbyName时,它就会向我显示mongo驱动程序的详细信息,等等。

0 个答案:

没有答案
相关问题