我不知道如何使用等同于" 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 :(得分:4)
您在查询中错过了$in
运算符:
db.mytestdb_profiles.find({
"account" : "foo",
"archivedFilteredEvents.id" : { $in: [ "all_events","f123dsad2"] } }
)