Tuesday, 6 June 2017

Node.js async taking too long to execute

I've got my array of queries

var array = [ 'UPDATE EVALUATION SET mark = "16" WHERE id_eval = "21" AND id_usr = "125"', 'UPDATE EVALUATION SET mark = "9" WHERE id_eval = "22" AND id_usr = "125"', 'UPDATE EVALUATION SET mark = "8" WHERE id_eval = "34" AND id_usr = "125"' ]

However, when I try to execute them all at once with async, my web page says Waiting for localhost... and it keeps on loading forever. What am I doing wrong?

async.forEach(array, function(query, callback){
        connection.query(query, function(err, rows, fields){
            if(err){
                return console.error(err);
            }
            callback();
        });

    }, function(err){
        if(err){
            return console.log(err);
        }
});



via Rockasaurus

No comments:

Post a Comment