我很难为这个问题选择合适的标题。我有一份文件和子文件清单如下
{
"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"
]
}
在此示例中,我们有两个主要类别 (“Pets”,“Entertainment”) 及其相应的子类别(“宠物”的猫和狗) ,...)。虽然有不同级别的子类别,但所有文档/子文档都有两个键, name和fbCategories 。我想在不编写循环或多个查询的情况下找到每个类别/子类别的fbCategories。无论如何在一个查询中查询它们,结果应列出每个“name”键的“fbCategories”。例如,对于“musicians”,它会列出["Concert Tour","Musician/Band"]
,而对于“音乐”,它会列出
["Concert Venue","Music Chart","Music Video","Musical Instrument","Record Label","Music"]