I have a variable in my Node function.
var storeId;
The value of storeId may or may not be undefined.
Now, if it is undefined, I do not want $match to filter out based on this parameter . If storeId has a value, $match should filter out based on storeId.
$match: {
type: "abc",
"_store._id":storeId?: //something like if else here
}
What should I add here ?
storeIdis undefined, then I use the query without_store._idand ifstoreIdhas some value then use the query with_store._id