How to query MongoDB with “like”?
I want to query something with SQL's
SELECT * FROM users WHERE name LIKE '%m%'
How to do I achieve the same in MongoDB? I can't find an operator for
like in the documentation.
That would have to be:
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.
note: mongodb uses regular expressions which are more powerful than "LIKE" in sql. With regular expressions you can create any pattern that you imagine.