mongodb中具有父子关系的树结构以供读取

时间:2019-07-06 11:28:22

标签: node.js mongodb mongoose

我想用一个父级的嵌套子级读取树结构中的数据,我正在使用mongodb。 enter image description here

我希望从mongodb获得这种类型的预期数据 [ { "_id": "5d1fd59b1d26b42b2fdecf69", "email": "admin@admin", "userName": "admin", "parrentId": "5d1fd9a6f612542b8d72337d", "childs": [ { "_id": "5d1fd61af612542b8d723376", "email": "test1@test.com", "userName": "test1", "parrentId": "5d1fd59b1d26b42b2fdecf69", "childs": [ { "_id": "5d1fd91af612542b8d723379", "email": "test2@test.com", "userName": "test2", "parrentId": "5d1fd59b1d26b42b2fdecf69", "childs": [] }, { "_id": "5d1fd91af612542b8d723379", "email": "test2@test.com", "userName": "test2", "parrentId": "5d1fd59b1d26b42b2fdecf69", "childs": [] },
] } ] } ]

0 个答案:

没有答案