Closed how1231 closed 2 years ago
Hello, and sorry you are having trouble. Yes, in Node.js using async callbacks in a for loop doesn't work as you would like. Thankfully there is a great library that provides this functionality: https://www.npmjs.com/package/async
I'm trying to change mysql connection from mysql.createConnection(config) to mysql.createPool(config). So far most of the APIs required nothing much to change except for transaction.
Problem: There is a for loop going to execute query inside a pool transaction callback hell. But the loop was not waiting for the callback to finish.
Original code which is working fine
Present code which got problem
Question: Does anyone has any idea on how to solve this kind of asynchronous problem?
ps: Sorry for the long question...I'm already stuck at here for few days, any help would be appreciated, thanks in advance!