Trying to query the database with this code: I have a string within 'nameInput' that I want to find documents that contain it.
var arg = {"$and":[{"name":{'$regex' : nameInput, '$options' : 'i'}}, {"thing": selectedThing}]}
I plug in arg into the find() method and it returns this error: errors.js:20 Uncaught (in promise) Error: $regex requires regular expression
Any idea how this can be fixed? I've tried replacing nameInput by using the RegExp method in Javascript to no avail. (e.g new RegExp(nameInput, 'i'))