【发布时间】:2017-03-23 20:04:15
【问题描述】:
编辑
我现在意识到我的查询有两个问题。
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 的时候。
【问题讨论】:
标签: node.js mongodb express mongoose database