like operator in mongodb code example

Example 1: mongodb find like

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

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

Items.find({"description": {$regex: ".*" + variable + ".*"}}).fetch();

Example 2: 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.

Example 3: like mongodb

db.collection.find( { "url": { "$regex": ".*a.*"} } );

Example 4: like in mongodb

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

Example 5: like in mongodb

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

Tags:

Misc Example