Mongodb 查询中与sql等效的给定值列表

Mongodb 查询中与sql等效的给定值列表,mongodb,mongodb-query,Mongodb,Mongodb Query,我一直在试图弄清楚如何在MongoDB中使用与IN-sql等效的工具,因为我没有得到任何结果 以下是记录/文件的示例输出: [ { "_id" : ObjectId("12348749e4b04b2d017ff78e"), "account" : "foo", "archivedFilteredEvents" : [ {

我一直在试图弄清楚如何在MongoDB中使用与IN-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');
您只是在查询中缺少运算符:

db.mytestdb_profiles.find({
 "account" : "foo", 
 "archivedFilteredEvents.id" : { $in: [ "all_events","f123dsad2"] } }
)
您只是在查询中缺少运算符:

db.mytestdb_profiles.find({
 "account" : "foo", 
 "archivedFilteredEvents.id" : { $in: [ "all_events","f123dsad2"] } }
)
以下是文件:以下是文件: