A quick snippet for anyone looking for equivalent SQL LIKE queries for mongodb.
db.users.find({name: /a/})
SELECT * FROM USERS WHERE name LIKE '%a%';
db.users.find({name: /^ja/})
SELECT * FROM USERS WHERE name LIKE 'ja%'
db.users.find({name: /jo$/})
SELECT * FROM USERS WHERE name LIKE '%jo'
Top comments (0)