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 -7
View File
@@ -1,10 +1,8 @@
import { pool } from '.';
import { logError, profileBatchStatements, runProfiler } from '../logger';
import { CFXCallback, CFXParameters, QueryType } from '../types';
import { parseResponse } from '../utils/parseResponse';
import { executeType, parseExecute } from '../utils/parseExecute';
import { scheduleTick } from '../utils/scheduleTick';
import { isServerConnected, waitForConnection } from '../database';
import { getPoolConnection } from './connection';
import { setCallback } from '../utils/setCallback';
export const rawExecute = async (
@@ -28,11 +26,9 @@ export const rawExecute = async (
return logError(invokingResource, cb, isPromise, 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);