I want to use code to manipulate 'condition' as variable before passing into 'find' method (for MongoDB):
let condition;
if (cat) {
condition = { $and: [{brand: brnd},
{category: cat} ]
}
} else {
condition = {brand: brnd}
}
productCol.find(condition);
But I am unable to get this to work. Can anyone help me how I can make it to work? Thank you