MongoDB Like Query

How to Emulate SQL's LIKE in MongoDB Using Regex


MongoDB:  db.users.find({"name": /jo/}) — This regex pattern matches any name that contains "jo".

MySQL Equivalent:  SELECT * FROM users WHERE name LIKE '%jo%' — The % wildcard precedes and follows the search term.

No comments :

Post a Comment

Your Comment and Question will help to make this blog better...