In mongodb the equivalent to sql "like" operator is
db.users.find({"shows": /m/})
Using nodejs/javascript I want to dynamically change letter, based on url paramater.
I have tried
letter = req.params.letter;
db.users.find({"shows": '/' + letter + '/'})
This doesn't work, I guess because the slashes are now strings are interpreted differently.
One way to do it, according to the documentation page:
db.users.find( { shows : { $regex : letter } } );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With