Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested (embedded) tree model in loopback with mongodb

I try to figure out how to set a very simple nested "treenode" model in loopback with mongodb. The idea is there will be only one model (for this): treenode which can contain other treenodes. I would like to store them at once via mongodb nested documents:

- TreeNode (document):
  Name: "A",
  Nodes: [          
     { 
       Name: "A-A",
       Nodes: [
          { 
            Name: "A-A-A",
            Nodes: []
          },
          { 
            Name: "A-A-B",
            Nodes: []
          },
          { 
            Name: "A-A-C",
            Nodes: []
          }         
      },       
      { 
       Name: "A-B",
       Nodes: []       
      },  
  ]

Additionally each node at any level has relations to other models.

There will be many top-level root treenodes (documents). Which relation type and how should I use for this?

like image 854
ggabor Avatar asked Apr 16 '26 08:04

ggabor


1 Answers

Unfortunately, there isn't much documentation on this topic yet. For now, see http://docs.strongloop.com/display/LB/Embedded+models+and+relations

like image 178
superkhau Avatar answered Apr 18 '26 00:04

superkhau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!