var results = sqlQuery(sql)
function sqlQuery (sql) {
return new Promise((resolve, reject) => {
sql.query(/*query*/, function (error, results, fields) {
if (error) {
console.log(error)
reject(error)
}
resolve(results)
})
})
}
IMPORTANT : The code above is inside a while() that change the /*query*/ in each loop
I don't have a way of testing this, but try something like this, using a recursive function:
var results = sqlQuery(sql)
function sqlQuery (sql) {
return new Promise((resolve, reject) => {
sql.query(/*query*/, function (error, results, fields) {
if (error) {
return sqlQuery(sql).then(res => resolve(res));
}
resolve(results)
})
})
}
Although I have to say that redoing it over and over again just isn't the best idea...