diff --git a/.gitignore b/.gitignore index 1e9f773..cb9b7a1 100644 --- a/.gitignore +++ b/.gitignore @@ -131,3 +131,4 @@ dist .yarn/install-state.gz .pnp.* +credentials.json diff --git a/src/MariaDB.ts b/src/MariaDB.ts index 320fe28..580cd01 100644 --- a/src/MariaDB.ts +++ b/src/MariaDB.ts @@ -149,6 +149,7 @@ class MariaDB { this.#pool?.removeAllListeners(); resolve(); }); + this.#pool = null; }); } @@ -179,7 +180,7 @@ class MariaDB { const connection = await this.getConnection(); try { const result = await new Promise((resolve, reject) => { - const q = connection.query({ timeout, sql: query }, values, (err, results, fields) => { + const q = connection.query({ timeout, sql: query }, [ values ], (err, results, fields) => { if (err) reject(err); else if (results) @@ -214,8 +215,8 @@ class MariaDB { } - q (query: string, values: (string | number | string[] | number[])[], timeout?: number) { - return this.query(query, values, timeout); + q (query: string, values: (string | number | string[] | number[])[], timeout?: number) { + return this.query(query, values, timeout); } } diff --git a/tests/test.js b/tests/test.js new file mode 100644 index 0000000..4082804 --- /dev/null +++ b/tests/test.js @@ -0,0 +1,25 @@ +import { readFileSync } from 'fs'; +import { MariaDB } from '../build/esm/index.js'; + +const credentials = JSON.parse(readFileSync('./credentials.json', { encoding: 'utf-8' })); + +const maria = new MariaDB({ + createLogger: () => { + return { + debug: console.log, + info: console.log, + status: console.log, + warn: console.log, + error: console.error + }; + } +}, { + load: true, + credentials +}); + +await maria.init(); + +await maria.query('INSERT INTO `test` (`dingle`, `bingle`) VALUES ?', [[ 1, 2 ], [ 3, 4 ], [ 5, 6 ]]); + +await maria.close(); \ No newline at end of file