If I have a resource in the database, I know I can use the mongodb npm package in my express app to filter something with $gt, $lt, etc. to only receive back the values based on my desired filter.
I also know how to use req.query in combination with mongodb to retrieve results of my query strings when they're equal to something (URL: http://localhost:3000/fruit?type=apple, Express/mongodb: collection.find(req.query)...).
How do I make it so the query string indicates I want only the values that are greater than or less than something? If I just wanted "equal to", I would just pass it in as another query parameter (http://localhost:3000/fruit?type=apple&price=1), but what if I want all fruits whose prices are less than 1?
collection.find(req.query)unless you're validatingreq.querybeforehand. You'd be exposing yourself to request injection and someone could walk through your db pretty easily just by doingcollection.find({})