I have two async functions,
async function sqlPushSteamappid(appId){
let tmp;
let sql='INSERT INTO cleetusbot.tmp (appId) VALUES ('+appId+');';
tmp = new Promise((res, rej) => {
global.pool.query(sql, function (err, results, fields) {
if(err){
console.log(err);
}
});
});
return await tmp;
}
and
async function sqlGetSteamNames(){
let tmp;
let sql='SELECT * FROM cleetusbot.steamGames INNER JOIN tmp ON cleetusbot.steamGames.appId = cleetusbot.tmp.appId;';
tmp = new Promise((res, rej) => {
global.pool.query(sql,function (err, results, fields) {
if(err){
console.log(err);
}
res(results);
});
});
await tmp;
return tmp;
}
Both return what I need, however most of the time when they are called the MySQL queries either don't fully return completely, or don't return an answer at in within the promise. Am I missing something in my code or do I have to make the MySQL timeout longer? Here is how im calling them in my code:
for(let i = 0; i < gameList.length; i++){
sqlPushSteamappid(gameList[i]);
}
//sometimes does not return anything
let steamNameObj = await sqlGetSteamNames();