Javascript: Relational nested JSON -


i've been using nedb persistent data storage model in electron/angular application. setup of data works main purpose of application. show table "0" , when use clicks on options takes them items table "1" have "foreign" matches "key" selected item table "0". other 1:n relational data.

i want display objects in accordion fashion users able interact relationships. want able recursively, cannot seem wrap head around it.

a chunk flat json file this:

{"_id":"000000","type":"dc","table":"0","key":"a","cat":"cad assessment","foreign":"a"} {"_id":"000002","type":"dc","table":"1","key":"1","cat":"coronary angiography or without left heart catheterization , 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"} 

and want this:

{     "_id":"000000",     "type":"dc",     "table":"0",     "key":"a",     "cat":"cad assessment",     "foreign": [         {             "_id":"000002",             "type":"dc",             "table":"1",             "key":"1",             "cat":"coronary angiography or without left heart catheterization , 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"                 }             ]         }     ] } 

is possible thing? i'm hoping lot more experience can point me in right direction here. i'm ready stop banging head against wall.


Comments

Popular posts from this blog

Receive udp packets in android gstreamer -

php - Extract Text from HTTP referer -

authentication - Mongodb revoke acccess to connect test database -