filteredListings = await Listing.aggregate([
{ $match: { category: req.params.category } },
{ price: { $lt: 150 } }
]);
As you can see, I'm trying to get all listings with a field price of less than 150. what is the correct way of doing that?
CodePudding user response:
You need to add it in $and
operator inside the $match
statement
filteredListings = await Listing.aggregate([
{ $match: { $and: [{ category: req.params.category }, { price: { $lt: 150 } }] } }
]);