I have checked various posts already made on this topic before , but none of the suggestion worked for me. I have seen those suggestions will not work in mongoose 5.0. I am using mongoose 5.6. I tried with find(), which is working. but I need aggregation fm for extended usage. most of the suggestions were on converting record id mongoose.Types.ObjectId() which I used . but not worked me. pl help

here is my test code.

function totalActualSale (recordId) {

```
Record.aggregate([
    {  
      $match : {
        '_id':mongoose.Types.ObjectId(recordId),
      }
    },
    {
        $unwind:  { "path": '$SalesList'}
    },
    { $group:
        {_id:
            {
                item:"$SalesList.item",
            },
            pqty: { $sum: '$SalesList.pqty' },
        }
    },
    ], function (err, purc) {

        console.log("\nStock:"+ JSON.stringify(purc));

});

```

}