【发布时间】:2016-04-30 01:44:27
【问题描述】:
我正在尝试将regex 与$in 运算符一起使用,如文档中所述,但我仍然无法获得该值。
db.users.find({'profile.firstName':{$in:["/justin/i"]}}).count() = 0
但是当我这样使用时
db.users.find({'profile.firstName':{$in:["justin"]}}).count()=1
和
db.users.find({'profile.firstName':{$in:["Justin"]}}).count()=2
已编辑问题
似乎我不清楚问题,我将添加代码以便于理解
我正在尝试从不区分大小写的查询中获取文档列表。我认为最好用代码来解释我的疑问。
Meteor.users.find({'profile.firstName':{$in:[/justin/i,/helen/i]}}).count()
将给出profile.firstName为justin/Justin/JUSTIn/HElen/helen的文档
但我怀疑如何用变量 x=["sai","test","jacob",---etc] 代替 helen/justin
【问题讨论】: