I want to call a function main() which contains a lot of asynchronous db-connection calls. I want to call this function repeatedly after an iteration of main() gets finished.
How should I do that in Nodejs? I think there is some way to use promises over here to do this. But I am not able to think in the correct direction.
Use Promise.all to wait for all promises to finish.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all
Afterwards you can call
.then(main)