Skip to content

Commit

Permalink
Merge pull request #848 from MartnReus/fix/mysql-conection-timeout
Browse files Browse the repository at this point in the history
fix(database): MySQL conection timeout
  • Loading branch information
leifermendez authored Sep 9, 2023
2 parents eade995 + 8391037 commit aedd4b1
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions packages/database/src/mysql/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,27 @@ class MyslAdapter {
})
}

getPrevByNumber = (from) =>
new Promise((resolve, reject) => {
const sql = `SELECT * FROM history WHERE phone='${from}' ORDER BY id DESC`
getPrevByNumber = async (from) => {
if (this.db._closing) await this.init()
return await new Promise((resolve, reject) => {
const sql = `SELECT * FROM history WHERE phone='${from}' ORDER BY id DESC`;
this.db.query(sql, (error, rows) => {
if (error) {
reject(error)
reject(error);
}

if (rows.length) {
const [row] = rows
row.options = JSON.parse(row.options)
resolve(row)
const [row] = rows;
row.options = JSON.parse(row.options);
resolve(row);
}

if (!rows.length) {
resolve(null)
resolve(null);
}
})
});
})
}

save = (ctx) => {
const values = [
Expand Down

0 comments on commit aedd4b1

Please sign in to comment.