2016-11-09 57 views
0

编辑MongoDB的猫鼬排除从查询结果由布尔值

我现在意识到我有两个问题,我的查询。

1(我原来的问题):

在节点/快递我试图通过一个布尔值过滤从Mongo的查询结果。应该很简单吧?基本上,如果配置文件不完整,我想忽略用户。

这是一个不打球查询的特定部分:

{profileComplete: {$ne: false}} 

我试过换$ne$nin,但这种简化版,工作要么。

难道我得到的东西错在该查询?

这里就是整个查询的情况下,这是有用的:

req.session.query = {$and: 
    [ 
    {learningLanguages: {$in: req.user.spokenLanguages}}, // matches other users' learning languages with the current users spoken language(s) 
    {_id: {$nin: [req.user.blockedUsers.split(","), req.user._id]}}, // disregard users who have been blocked by the current user AND the current user him/herself 
    {profileComplete: {$ne: false}} // disregard users who haven't completed their profiles yet. 
    ] 
} 

2:

我也刚刚发现,阻断自己的登录用户从结果不工作要么。这是该行查询的最后一位:{_id: {$nin: [req.user.blockedUsers.split(","), req.user._id]}}

正当我虽然我正在认真处理的MongoDB。

回答

0

好的我想通了。它一直在工作,但我在其他地方(不是很远!)有一个if语句,它正在创建一个不同的查询。卫生署!