2016-11-09 61 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語句,它正在創建一個不同的查詢。衛生署!