Relatively Simple Scenario:
I have this Voucher object which has a user property (of type ObjectId). I want to get the sum of
Voucher
user
ObjectId
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.
mongoose.Schema.Types.ObjectId
mongoose.Types.ObjectId