unable to use $match operator for mongodb/mongoose aggregation with ObjectId

后端 未结 4 1748
攒了一身酷
攒了一身酷 2020-12-16 15:03

Relatively Simple Scenario:

I have this Voucher object which has a user property (of type ObjectId). I want to get the sum of

4条回答
  •  既然无缘
    2020-12-16 15:58

    use toString() method.

    { $match : { user : user_id.toString() , expires : { $gt : new Date() } } }

提交回复
热议问题