Relatively Simple Scenario:
I have this Voucher object which has a user property (of type ObjectId). I want to get the sum of
When using the find method or findById the query can be only:
var query = {
$or: [
{'_sender':req.body._id},
{'_recipient':req.body._id}
]
};
When using aggregate the query need a cast
var mongoose = require('mongoose');
var query = {
$or: [
{'_sender':new mongoose.Types.ObjectId(decoded._id)},
{'_recipient':new mongoose.Types.ObjectId(decoded._id)}
]
};