Closed xpsion closed 7 years ago
@xpsion , What's in a data
?
Give an example, please
[{ "id" : 6000, "parent" : 0 } { "id" : 6001, "parent" : 6000 } { "id" : 6002, "parent" : 6000 } { "id" : 6003, "parent" : 6000 } { "id" : 6004, "parent" : 6000 } { "id" : 6005, "parent" : 6000 } { "id" : 6006, "parent" : 6000 } { "id" : 6007, "parent" : 6000 } { "id" : 6008, "parent" : 6001 }]
data = JSON.parse(JSON.stringify(data));
Finally It Has Worked!
Why need this conversion?
@xpsion , I checked your data
and created PR - https://github.com/DenQ/list-to-tree/pull/10
All working without convertation and passed tests
thank you~ Strange, why use mongoose find results can not directly use
uMode.find({}, (err,data) => { let ltt = new LTT(data, { key_id: 'id', key_parent: 'parent' }); let tree = ltt.GetTree(); console.log(tree); }