收藏
回答

怎么复制一个方法或者是,函数,或者啥,?

首先声明

      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互不干扰?

回答关注问题邀请回答
收藏
登录 后发表内容