首先声明
var agg=db.collection('order').aggregate().match({
parted: 30001,
"way.0": _.in([20001,20002]),
"way.1.addressDetailBuilding": addressDetailBuilding,
"way.1.addressDetailJQ": addressDetailJQ,
"situation.paid.0":true
})
.project({
dorm: $.arrayElemAt(["$way",1]),
time: $.arrayElemAt(['$situation.paid',1]),
totalPrice: '$totalPrice'
})
.group({
_id: '$dorm.addressDetailDorm',
lastTime: $.max('$time'),
totalMoney: $.sum("$totalPrice"),
amount: $.sum(1)
});
然后 total=(await agg.count('total').end()).list[0].total;
再然后 list: await agg.sort({ _id:1 }).end()
我发现后面的list会受到total的影响;
怎么确保两次使用的agg互不干扰?