mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-01 14:38:50 +00:00
fix: Initialize resource array before using it
This commit is contained in:
1 parent
b0f25778fd
commit
8fb5ca2e8c
1 file changed
+11
-7
+11
-7
@@ -1,12 +1,14 @@
|
||||
import { mysql_debug, mysql_slow_query_warning, mysql_ui } from '../config';
|
||||
import type { CFXParameters } from '../types';
|
||||
|
||||
interface QueryData {
|
||||
date: number;
|
||||
query: string;
|
||||
executionTime: number
|
||||
}
|
||||
|
||||
type QueryLog = {
|
||||
[invokingResource: string]: {
|
||||
date: number;
|
||||
query: string;
|
||||
executionTime: number;
|
||||
}[];
|
||||
[invokingResource: string]: QueryData[];
|
||||
};
|
||||
|
||||
const logStorage: QueryLog = {};
|
||||
@@ -20,15 +22,17 @@ export const logQuery = (invokingResource: string, query: string, executionTime:
|
||||
|
||||
if (!mysql_ui) return;
|
||||
|
||||
if (logStorage[invokingResource] === undefined) logStorage[invokingResource] = []
|
||||
logStorage[invokingResource].push({ query, executionTime, date: Date.now() });
|
||||
|
||||
};
|
||||
|
||||
RegisterCommand(
|
||||
'mysql',
|
||||
() => {
|
||||
(source: number) => {
|
||||
if (!mysql_ui) return;
|
||||
|
||||
emitNet(`oxmysql:openUi`, logStorage);
|
||||
emitNet(`oxmysql:openUi`, source, logStorage);
|
||||
},
|
||||
true
|
||||
);
|
||||
Reference in new issue
Block a user