Aggregate One-to-Many Relationship in MongoDB with Subdocument References -


consider document 2 arrays, lines , nodes each containing many sub-documents , add'l nested documents not shown clarity

{     {"lines": [         {             "guid": 1             "def": {                 "n1": 49,                 "n2": 50             }         },         ...]     },     {"nodes": [         {             "guid": 49,             "def": {                 "x": -43.9709,                 "y": 14.8688,                 "z": -121.988             }         },         {             "guid": 50,             "def": {                 "x": -30.5955,                 "y": 29.5512,                 "z": -115.024             }         },         ...]     } } 

how 1 query mongo return restructured document of lines, pulling need nodes?

{     {"lines": [         {             "guid": 1             "def": {                 "n1": {                     "guid": 49,                     "def": {                         "x": -43.9709,                         "y": 14.8688,                         "z": -121.988                     }                 }                 "n2": {                     "guid": 50,                     "def": {                         "x": -30.5955,                         "y": 29.5512,                         "z": -115.024                     }                 }             }         },         ...]     } } 

coming healthy understanding of rdbms, , new mongodb. i've been spending lot of time hacking away aggregation framework try , achieve this, having no luck. there simple missing?

i expect alternate data model might more appropriate. above no doubt start crash against 16 mb bson document limit concerning use case.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -