how to query mongodb with like
db.users.find({"name": /.*m.*/});
db.users.find({"name": /m/});
Items.find({"description": {$regex: ".*" + variable + ".*"}}).fetch();
4.22
13
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.
Thank you!
13
0
3.67
6
db.users.find({"name": /m/})
Thank you!
6
0
4
8
db.collection.find( { "url": { "$regex": ".*a.*"} } );
Thank you!
8
0
Are there any code examples left?
New code examples in category Other