比如云数据库中order订单数据是这样的
[{orderId:1,goodsList:[{name:"apple",price:5},{name:"banana",price:8}]},{orderId:2,goodsList:[{name:"apple",price:5},{name:"banana",price:8}]}]
怎么查询可以得到goodsList的集合
[{name:"apple",price:5},{name:"banana",price:8},{name:"apple",price:5},{name:"banana",price:8}]
这样的结果
aggregate()
.match()
.unwind('goodsList')
.group({
_id:'$name',
price:...
count:...
sum:...
total:...
})