How to query MongoDB with “like”?

后端 未结 30 2063
予麋鹿
予麋鹿 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:36

    If you are using Spring-Data Mongodb You can do this in this way:

    String tagName = "m";
    Query query = new Query();
    query.limit(10);        
    query.addCriteria(Criteria.where("tagName").regex(tagName));
    

提交回复
热议问题