在mongo db中查找记录,在某些字段上使用正则表达式搜索会得到错误答案

时间:2018-03-15 06:40:37

标签: node.js mongoose

我有查询,

db.getCollection(collection).find({$and: [
  {street: {$regex: new RegExp('7/838(B) Seaport - Airport Road', 'i')}}
]})

db包含确切的数据,但不返回任何内容。如何编写正确的查询以获得结果?

1 个答案:

答案 0 :(得分:0)

试试这个,你不需要$和那个。

db.getCollection('collection').find({"street" : new RegExp("7/838(B) Seaport - Airport Road","i")})