MongoDB Fund wie
db.users.find({"name": /.*m.*/});
db.users.find({"name": /m/});
Items.find({"description": {$regex: ".*" + variable + ".*"}}).fetch();
Concerned Chipmunk
db.users.find({"name": /.*m.*/});
db.users.find({"name": /m/});
Items.find({"description": {$regex: ".*" + variable + ".*"}}).fetch();
db.collection.find( { "url": { "$regex": ".*a.*"} } );
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.
db.users.find({"name": /m/})
db.users.find({"name": /.*m.*/})
-- mongodb
db.people.find( { user_id: /bc/ } )
-- or
db.people.find( { user_id: { $regex: /bc/ } } )
-- sql
SELECT *
FROM people
WHERE user_id like "%bc%"
-- mongodb
db.people.find( { user_id: /^bc/ } )
-- or
db.people.find( { user_id: { $regex: /^bc/ } } )
--sql
SELECT *
FROM people
WHERE user_id like "bc%"