What can be used instead of classicasync.waterfall in Nodejs?

31 Views Asked by At

I am retrieving data from mysql database using Nodejs. Previously, I used to use mysql package but now I am using mysql2 package since it has promises integrated. Now, the question is if I have to run multiple tasks which depend on the output of previous task, what can I use instead of async.waterfall(tasks, callback)? Also, I would like to know if I need to implement promise keyword if it is already in mysql2?

example code:

async function(req, res){
var dbquery = "select ....."

    classicasync.waterfall([
       function(callback){
         db.getconnection(function(err, connection){
           (async()=>{
              db.query = util.promisify(db.query);
               let product = await db.query(dbquery)

          })
        callback(null, 'Task1', 'Task 2');
       },
      function(arg1, arg2, callback){
         ........
        callback(null, arg3)
    },
     function(arg1, callback){
       arg1 += 'completed';
       callback(null, arg1);
    }
    ], function(err, result){
         console.log(result);
    });

This is a huge function, so I couldn't write all of it.

Thank you for your help.

0

There are 0 best solutions below