我很难为这个问题选择正确的标题。我有如下文件和子文件列表
{
"name" : "Pets",
"subcategories" : [
{
"name" : "Cats",
"fbCategories" : []
},
{
"name" : "Dogs",
"fbCategories" : []
}
],
"fbCategories" : ["Pet Services","Pet Supplies", "Animal"]
},
{
"name" : "Entertainment",
"subcategories" : [
{
"name" : "Music",
"subcategories" : [
{
"name" : "Albums",
"fbCategories" : [ "Album"]
},
{
"name" : "Musicians",
"fbCategories" : ["Concert Tour","Musician/Band"]
}
],
"fbCategories" : [
"Concert Venue",
"Music Chart",
"Music Video",
"Musical Instrument",
"Record Label",
"Music"
]
}
在此示例中,我们有两个主要类别(“宠物”、“娱乐”)及其对应的子类别(“宠物”的猫和狗,...)。虽然有不同级别的子类别,但所有文档/子文档都有两个键,name 和 fbCategories。我想在不编写循环或多个查询的情况下找到每个类别/子类别的 fbCategories。无论如何要在一个查询中查询它们,结果应该列出每个 “名称”键的“fbCategories” 。例如对于“音乐家” ,它将列出,而对于“音乐”,它将列出["Concert Tour","Musician/Band"]
["Concert Venue","Music Chart","Music Video","Musical Instrument","Record Label","Music"]