mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-02 22:22:50 +00:00
refactor(database): move from mysql2/promise to callback api
Micro-optimisation for rawQuery. rawExecute and rawTransaction will still utilise the promise api (pool.promise()).
This commit is contained in:
1 parent
dd05cb8e68
commit
dea98f7c5b
5 files changed
+22
-33
No files matched your search
+6
-10
@@ -1,4 +1,4 @@
|
||||
import { createPool, QueryError, Pool } from 'mysql2/promise';
|
||||
import { createPool, Pool } from 'mysql2';
|
||||
import { connectionOptions, mysql_transaction_isolation_level } from '../config';
|
||||
import { typeCast } from '../utils/typeCast';
|
||||
|
||||
@@ -12,15 +12,11 @@ setTimeout(() => {
|
||||
typeCast,
|
||||
});
|
||||
|
||||
pool
|
||||
.query(mysql_transaction_isolation_level)
|
||||
.then(() => {
|
||||
console.log(`^2Database server connection established!^0`);
|
||||
serverReady = true;
|
||||
})
|
||||
.catch((e: QueryError) =>
|
||||
console.error(`^3Unable to establish a connection to the database! [${e.code}]\n${e.message}^0`)
|
||||
);
|
||||
pool.query(mysql_transaction_isolation_level, (err) => {
|
||||
if (err) return console.error(`^3Unable to establish a connection to the database!\n^3[${err}]^0`);
|
||||
console.log(`^2Database server connection established!^0`);
|
||||
serverReady = true;
|
||||
});
|
||||
});
|
||||
|
||||
export { pool, serverReady };
|
||||
Reference in new issue
Block a user