I am using node-mysql, node-js, and Q promises.
I have successfully updated, deleted, and inserted single rows using the above. As well as inserted multiple rows in
Don't know if this problem it's still relevant but I will give my 2 cents:
The solution that I found is to use Promise.all
Basically you need to build an array of promises, where every promise is an update statement:
const getUpdatePromise = (row) => {
return new Promise( (resolve, reject) => {
mysqlConnection.query('UPDATE tableName SET foo = ? WHERE bar = ?', [row[0], row[1], (error, results, fields) => {
if (error) reject(error)
resolve(results)
});
})
}
You add this new Promise into an array and pass the final array with all the update statements to the Promise.all function.
It worked for me. Hope it works for someone else.