Answers for "how to query mongodb with like"

7

mongodb find like

db.users.find({"name": /.*m.*/});

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

Items.find({"description": {$regex: ".*" + variable + ".*"}}).fetch();
Posted by: Guest on May-21-2020
1

how to query mongodb with like

db.users.find({"name": /m/})
or
db.users.find({"name": /.*m.*/})

You're looking for something that contains "m" somewhere
(SQL's '%' operator is equivalent to Regexp's '.*'), 
not something that has "m" anchored to the beginning of the string.
Posted by: Guest on March-20-2021
2

like mongodb

db.collection.find( { "url": { "$regex": ".*a.*"} } );
Posted by: Guest on March-20-2021
1

like in mongodb

db.users.find({"name": /m/})
Posted by: Guest on July-31-2020

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language