louischatriot / nedb

The JavaScript Database, for Node.js, nw.js, electron and the browser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

IceBotYT opened this issue · comments

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!

Nevermind, I thought of a fix. Thanks!