云函数云数据库日期比较怎么写?
需求很简单,把当天(国庆当天)订单所有金额合计一下,调试不出来,查阅了论坛都提到数据库聚合日期比较没法比呀:
const res = await db.collection('orders') .aggregate() .addFields({ matched: $.and([$.gt(['$addTime', new Date('10/1/2019')]), $.lt(['$addTime', new Date('10/2/2019')])]) }) .match({ sellerId: openid, status: $.neq(-1), matched: true }) .group({ _id: null, totalFinalSum: $.sum('$finalSum') }) .end() |
