{
"name":"food",
"core":{
"group":{
"carbs":{
"USA":{
"breakfast":"potatoes",
"dinner":"pasta"
},
"europe":{
"breakfast":"something",
"dinner":"something"
}
},
"dessert":{
"USA":{
"breakfast":"potatoes",
"dinner":"pasta"
},
"europe":{
"breakfast":"something",
"dinner":"something"
}
},
"veggies":{
"USA":{
"breakfast":"potatoes",
"dinner":"pasta"
},
"europe":{
"breakfast":"something",
"dinner":"something"
}
}
}
}
}
我正试图找到一种方法来回归核心群体(碳水化合物,甜点和蔬菜)。
我有以下python代码但它返回文档中的所有值,当我只对core.group感兴趣时
data = collection.foodie.find({"name":"food"},{"name":False, '_id':False, "core.groups.carbs.europe":False, "core.groups.dessert.europe":False, "core.groups.veggies.europe":False
最终结果是一个INI文件,其组类型为美国的部分名称,如下所示,这就是为什么我正在寻找一种方法来列出组,以便我可以动态查找存储的实际值当我不知道这些群体时(将它们硬编码为core.group.dessert.europe)
[carbs]
breakfast=potatoes
dinner=pasta
[dessert]
breakfast=potatoes
dinner=pasta
[veggies]
breakfast=potatoes
dinner=pasta