Native Javascript ES5/ES6 Promises
I'm trying to import data that has a recursive relationship and since the database(mongodb) is assigning ids - a parent has to be loaded(asynchrnously) before it's children can be loaded(also async).
For example, Task B in this list of tasks.
Task A - Some Process
Task B - Recursive Async Loading(bread-first traverse)
Task C - Dependent on Task B
Notice since Task C can't be started until Task B is complete I assume a promise chain will need to be built that doesn't exit until it is done.
The assume the chain being built would look something like this: (the tree has only 1 head)
promiseParent.then(Promise.all(childrenPromises.then(Promise.all(grandChildrenPromsies.then(....)))))
I imagine it would traverse like a breadth-first queue (preferable I would like to try to avoid using a queue data structure if it's possible)
I found this one to be a tough one to crack. Any suggestions or solutions?