Quantcast
Channel: How to query MongoDB with "like" - Stack Overflow
Viewing all articles
Browse latest Browse all 48

Answer by Lazaro Fernandes Lima Suleiman for How to query MongoDB with "like"?

$
0
0

If you have a string variable, you must convert it to a regex, so MongoDb will use a like statement on it.

const name = req.query.title; //Johndb.users.find({ "name": new Regex(name) });

Is the same result as:

db.users.find({"name": /John/})


Viewing all articles
Browse latest Browse all 48

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>