我在Electron / Angular应用程序中一直使用NeDB作为持久数据存储模型。这些数据的设置完全适用于我的应用程序的主要目的。我从表“0”显示所有内容,当用户点击一个选项时,它会将它们带到表“1”中的所有项目,这些项目的“外来”与表“0”中所选项目中的“键”相匹配。像任何其他1:n关系数据一样。
我希望以手风琴般的方式显示对象,以便我的用户能够与关系进行交互。我想能够递归地做到这一点,但似乎无法绕过它。
我的平面JSON文件中的一块是:
{"_id":"000000","type":"dc","table":"0","key":"A","cat":"CAD Assessment","foreign":"A"}
{"_id":"000002","type":"dc","table":"1","key":"1","cat":"Coronary angiography with or without left heart catheterization and left ventriculography","foreign":"A"}
{"_id":"000005","type":"dc","table":"2","key":"1.1","cat":"Suspected or known ACS","foreign":"1"}
{"_id":"000006","type":"dc","table":"2","key":"1.2","cat":"Suspected CAD: No prior noninvasive stress imaging (no prior PCI, CABG, or angiogram showing >=50% angiographic stenosis)","foreign":"1"}
我希望它看起来像这样:
{
"_id":"000000",
"type":"dc",
"table":"0",
"key":"A",
"cat":"CAD Assessment",
"foreign": [
{
"_id":"000002",
"type":"dc",
"table":"1",
"key":"1",
"cat":"Coronary angiography with or without left heart catheterization and left ventriculography"
"foreign": [
{
"_id":"000005",
"type":"dc",
"table":"2",
"key":"1.1",
"cat":"Suspected or known ACS",
"foreign":"1"
},
{
"_id":"000006",
"type":"dc",
"table":"2",
"key":"1.2",
"cat":"Suspected CAD: No prior noninvasive stress imaging (no prior PCI, CABG, or angiogram showing >=50% angiographic stenosis)",
"foreign":"1"
}
]
}
]
}
这甚至可能是一件事吗?我希望有更多经验的人可以在这里指出我正确的方向。我已经准备好不再把头撞在墙上了。