我要过滤名称字段以“ ab”开头的集合。
如何使用过滤器(例如)
Filters.regex("name","regex pattern")
答案 0 :(得分:2)
如果要在集合中找到名称以“ ab”开头的名称,则查询为:
//For case sensitive
db.collection.find({ 'name':/^ab/ });
//For case insensetive -pass the i flag
db.collection.find({ 'name':/^ab/i });