修改
我现在意识到我的查询存在两个问题。
1(我原来的问题):
在Node / Express中我试图通过布尔值过滤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 :(得分:0)
好的,我明白了。它一直在工作,但我在其他地方(不是很远!)有一个if语句,它创建了一个不同的查询。卫生署!