louischatriot / nedb

The JavaScript Database, for Node.js, nw.js, electron and the browser
MIT License
13.48k stars 1.02k forks source link

Search for JSON object using a variable using .find() #662

Closed IceBotYT closed 3 years ago

IceBotYT commented 3 years ago

Hello!

I am making a search function for my project using ExpressJS. The GET request will have parameters to search. A type, and the query. For example: http://localhost:3000/search?type=code&q=Google and with the find function, I get an error:

pwds.find({ req.params.type: req.params.q })
                   ^

SyntaxError: Unexpected token '.'

Is it possible to search for an object with a variable like this? Thanks!

IceBotYT commented 3 years ago

Nevermind, I thought of a fix. Thanks!