How to query MongoDB with “like”?

后端 未结 30 2133
予麋鹿
予麋鹿 2020-11-21 05:51

I want to query something with SQL\'s like query:

SELECT * FROM users  WHERE name LIKE \'%m%\'

How to do I achieve the same in

30条回答
  •  一生所求
    2020-11-21 06:09

    With MongoDB Compass, you need to use the strict mode syntax, as such:

    { "text": { "$regex": "^Foo.*", "$options": "i" } }
    

    (In MongoDB Compass, it's important that you use " instead of ')

提交回复
热议问题