2016-08-25 8 views
0

検索結果から特定のドキュメントを除外するにはどうすればよいですか?例えばマングース - 特定の文書の検索をスキップする方法は?

Stream.findOne({ 
    _id: query.id 
}, function(err, stream) { 

    var output = {}; 
    if (err) { 
     console.log("Error retrieving streams: " + err); 
    } 

    if (!stream) { 
     console.log("No stream found"); 
    } 

    if (stream) { 
     console.log("Stream found"); 
    } 
}); 

私はfindOne1234_idを探してスキップしたいです。

可能ですか?

答えて

1

あなたはMongoDB documentation for Logical Query Operators.

Stream.findOne({ $and : [ {_id: query.id } ,{ _id:{ $ne : "1234"} } ] 
}, function(err, stream) { 

    var output = {}; 
    if (err) { 
     console.log("Error retrieving streams: " + err); 
    } 

    if (!stream) { 
     console.log("No stream found"); 
    } 

    if (stream) { 
     console.log("Stream found"); 
    } 
}); 
を参照して、論理演算子の詳細については MongoDB Logical Query operators.

を使用してこれをやって試すことができます

関連する問題