Like in MongoDB Query


If you are familiar with SQL Server or another relation database, the  'LIKE' query look like as below.

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

In MongoDB, it looks 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

No comments:

Post a Comment

Please do not enter any spam link in the comment box.

NUnit : Introduction

There are several unit test tools in the market, but one of them is NUnit, the most popular tool for doing unit testing. So in this tutorial...