refactor(database): move pool and connection variables

Mostly reorganising module.
Added getPoolConnection helper.
This commit is contained in:
Linden committed 2023-09-15 14:36:31 +10:00
1 parent b3f4a7aa6b
commit 0398abc501
6 files changed
+78 -69

No files matched your search

+3 -6
View File
@@ -1,11 +1,10 @@
import { pool, isServerConnected, waitForConnection } from '.';
import { parseArguments } from '../utils/parseArguments';
import { setCallback } from '../utils/setCallback';
import { parseResponse } from '../utils/parseResponse';
import { logQuery, logError, runProfiler } from '../logger';
import type { CFXCallback, CFXParameters } from '../types';
import type { QueryType } from '../types';
import { scheduleTick } from '../utils/scheduleTick';
import { getPoolConnection } from './connection';
import { RowDataPacket } from 'mysql2';
export const rawQuery = async (
@@ -23,11 +22,9 @@ export const rawQuery = async (
return logError(invokingResource, cb, isPromise, `Query: ${query}`, err.message);
}
if (!isServerConnected) await waitForConnection();
const connection = await getPoolConnection();
scheduleTick();
const connection = await pool.getConnection();
if (!connection) return;
try {
const hasProfiler = await runProfiler(connection, invokingResource);