Aug 21, 2015

Like in MongoDB Query

In SQL, 'LIKE' query look like as below

SELECT * FROM [dbo.][USERS] WHERE FNAME LIKE '%DILIP%'

In MongoDB it's look like as below(query in MongoDB console)

db.USERS.find({"FNAME":/DILIP/})

Same as

db.USERS.find({"FNAME":/^DILIP/})   // FNAME LIKE 'DILIP%'

db.USERS.find({"FNAME":/DILIP$/})   // FNAME LIKE '%DILIP'

$regex in MongoDB