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

后端 未结 4 1745
攒了一身酷
攒了一身酷 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:55

    var aggregate  = [
    {
                    $match: {
                        'lenderId': new mongoose.Types.ObjectId(req.user),
                        '_disbursed': true
                    }
                },
                {
                    $unwind:'$emi'
                },
                {
                    $match: {
                        'emi._settled': false,
                    }
                }
    ];
    

提交回复
热议问题