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

后端 未结 4 1760
攒了一身酷
攒了一身酷 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 16:00

    Turns out the casting of the ObjectId seemed to be the issue. It was being cast using the Schema type Object Id mongoose.Schema.Types.ObjectId when it needed to be just a pure ObjectId mongoose.Types.ObjectId.

提交回复
热议问题