2016-06-27 9 views
1

私は結果が得られていないので、sqlの "IN"とMongoDBを使用する方法を理解しようとしています。ここでsqlに相当する値のリストを照会します

は、レコード/ドキュメントの出力例を示します。ここでは

[ 
     { 
       "_id" : ObjectId("12348749e4b04b2d017ff78e"), 
       "account" : "foo", 
       "archivedFilteredEvents" : [ 
         { 
           "id" : "all_events", 
           "name" : "All Events", 
           "enabled" : false 
         }, 
         { 
           "id" : "f123dsad2", 
           "name" : "test1", 
           "enabled" : true 
         } 
] 

は私が助けを必要とクエリです:

printjson(db.mytestdb_profiles.find({ 
"account" : "foo", 
"archivedFilteredEvents.id" : [ "all_events","f123dsad2"]} 
)); 

私は基本的に同等のを探しています:

select id, name, enabled 
from mytestdb_profiles 
where account = 'foo' 
and id.archivedFilteredDEvents IN ('all_events', 'f123dsad2'); 
+0

ここにドキュメントがあります:https://docs.mongodb.com/manual/reference/operator/query/in/#op._S_in – Hinrich

答えて

4

質問に$in演算子がありません:

db.mytestdb_profiles.find({ 
"account" : "foo", 
"archivedFilteredEvents.id" : { $in: [ "all_events","f123dsad2"] } } 
) 
関連する問題