{"name":"张1","sex":"男"}
{"name":"张2","sex":"男"}
{"name":"张3","sex":"男"}
{"name":"张1","sex":"男"}
{"name":"张2","sex":"男"}
{"name":"张2","sex":"男"}
.......
统计每个姓名的有多少人,怎么写?使用sum 不对吧,用什么那?
const $ = db.command.aggregate
db
.collection('test')
.aggregate()
.group({
_id: '$name',
totalPrice: $.sum('$name')
})
.end()
这不是有例子吗