mongoDB如何查询数组
可以这样查询吗:mongoDB如何查询数组,mongodb,mongoose,mongodb-query,Mongodb,Mongoose,Mongodb Query,可以这样查询吗: db.translations.find({'key'["select_trip_type_title","select_trip_type_title"]}}) 我的翻译集是这样的 { "_id" : ObjectId("5c8e6a53134bdd79eadb081e"), "status" : "active", "k
db.translations.find({'key'["select_trip_type_title","select_trip_type_title"]}})
我的翻译集是这样的
{
"_id" : ObjectId("5c8e6a53134bdd79eadb081e"),
"status" : "active",
"key" : "select_trip_type_title",
"default_value" : "Select Trip Tyoe ",
"value" : "Select Trip Tyoe ",
"operator" : ObjectId("5c8e6a52134bdd79eadb0812"),
"language" : ObjectId("5c8e6a52134bdd79eadb0814"),
"version" : 0.1,
"createdAt" : ISODate("2019-03-17T15:40:03.536Z"),
"updatedAt" : ISODate("2019-03-17T15:40:03.536Z"),
"__v" : 0
},{
"_id" : ObjectId("5c8e6a53134bdd79eadb081e"),
"status" : "active",
"key" : "select_trip_type_title",
"default_value" : "Select Trip Tyoe ",
"value" : "Select Trip Tyoe ",
"operator" : ObjectId("5c8e6a52134bdd79eadb0812"),
"language" : ObjectId("5c8e6a52134bdd79eadb0814"),
"version" : 0.1,
"createdAt" : ISODate("2019-03-17T15:40:03.536Z"),
"updatedAt" : ISODate("2019-03-17T15:40:03.536Z"),
"__v" : 0
},
{
"_id" : ObjectId("5c8e6a53134bdd79eadb0823"),
"status" : "active",
"key" : "set_location_on_map_action_positioning",
"default_value" : "positioning...",
"value" : "positioning...",
"operator" : ObjectId("5c8e6a52134bdd79eadb0812"),
"language" : ObjectId("5c8e6a52134bdd79eadb0814"),
"version" : 0.1,
"createdAt" : ISODate("2019-03-17T15:40:03.536Z"),
"updatedAt" : ISODate("2019-03-17T15:40:03.536Z"),
"__v" : 0
}
如果我有那些钥匙,我就去拿
我的主要任务是获得查询数组中的键与集合中的键之间的差异您可以使用以下运算符轻松完成此操作:
db.translations.find({
"key": {
$in: ["select_trip_type_title", "select_trip_type_short_trip"]
}
})
您可以使用以下运算符轻松完成此操作:
db.translations.find({
"key": {
$in: ["select_trip_type_title", "select_trip_type_short_trip"]
}
})
你的
translations
collection看起来像什么,实际上你想找到什么?类似于{“\u id”:ObjectId(“5c8e6a53134bdd79eadb081b”),“status”:“active”,“key”:“select\u trip\u type\u short\u trip”,“value”:“short trip”}我需要在所有的collection中查询,找出哪一个没有。获取类似于差异的内容?现在您的问题不清楚了,因为键
字段中没有类似于1,2,2或1,2,3的内容。请用详细信息更新您的帖子。您的问题实际上是查找所有关键文档,如“选择旅行类型”或“选择旅行类型”等?意思是数组中的任何内容[“select_trip_type_title”,“select_trip_type_short_trip”]
是的,我需要找到数组中的任何内容你的翻译集看起来像什么,你想找到什么?类似于{u id:ObjectId(“5c8e6a53134bdd79eadb081b”),“status”:“激活”,“键”:“选择行程类型”\u短行程”,“值”:“短行程”}我需要查询所有集合,并找到其中一个不存在。获取类似于diff的内容?现在您的问题不清楚了,因为key
字段中没有类似于1,2,2或1,2,3的内容。请用详细信息更新您的帖子。您的问题实际上是查找所有关键文档,如“选择旅行类型”或选择\u trip\u type\u short\u trip“等?表示数组中的任何内容[“选择\u trip\u type\u title”,“选择\u trip\u type\u short\u trip”]
是的,我需要在数组中查找任何内容