I want to do a MongoDB aggregation which first matches with some values and then groups them. But the field which has to be matched has values in the DB which have leading and trailing spaces in some of them. I want to first trim and then match them. How do I do that?
async AggregateTypes(_, { retailer_type }) {
const matchCond = {};
if(retailer_type) matchCond.cidm_retailer_type = {$in: retailer_type}
res = await collection.aggregate([
{
$match: matchCond
},
]);
}