I try to filter my outcome from MongoDB. I'm using an Express. Here are my console.logs:
- req.query.filters from URL: http://localhost:3000/test?filters=%7Bpersonalbest%3A%7B%27%24gt%27%3A%27170%27%7D%2Cname%3A%7B%27%24gt%27%3A%27M%27%7D%7D
- an object made by me to test if that works with my database and it does
- {personalbest:{'$gt':'170'},name:{'$gt':'M'}}
- { personalbest: { '$gt': '170' }, name: { '$gt': 'M' } }
Code:
var filters = req.query.filters
db.collection('skijumper').find(filters).toArray()
And of course I get this error:
MongoError: query selector must be an object
What is the best way to convert this req.query to an object ? Thanks