This commit is contained in:
Benjamin Toby
2025-08-05 15:27:07 +01:00
parent 43a741f9ac
commit eb98148533
23 changed files with 84 additions and 116 deletions
+5 -7
View File
@@ -1,10 +1,6 @@
import { DSQL_TableSchemaType, PostInsertReturn } from "../../types";
import { DSQL_TableSchemaType } from "../../types";
import { ConnectionConfig } from "mariadb";
type Param<T extends {
[k: string]: any;
} = {
[k: string]: any;
}> = {
type Param = {
query: string;
values?: string[] | object;
noErrorLogs?: boolean;
@@ -18,5 +14,7 @@ type Param<T extends {
*/
export default function dbHandler<T extends {
[k: string]: any;
} = PostInsertReturn>({ query, values, noErrorLogs, database, config, }: Param<T>): Promise<T[] | T | null>;
} = {
[k: string]: any;
}>({ query, values, noErrorLogs, database, config, }: Param): Promise<T[] | T | null>;
export {};
+5 -5
View File
@@ -27,16 +27,16 @@ function dbHandler(_a) {
try {
CONNECTION = yield (0, grab_dsql_connection_1.default)({ database, config });
if (query && values) {
const queryResults = (yield CONNECTION.query(query, values));
results = queryResults;
const queryResults = yield CONNECTION.query(query, values);
results = queryResults[0];
}
else {
const queryResults = (yield CONNECTION.query(query));
results = queryResults;
const queryResults = yield CONNECTION.query(query);
results = queryResults[0];
}
}
catch (error) {
console.log("Connection Info =>", CONNECTION === null || CONNECTION === void 0 ? void 0 : CONNECTION.getConfig());
console.log("Connection Info =>", CONNECTION === null || CONNECTION === void 0 ? void 0 : CONNECTION.info);
if (error.message &&
typeof error.message == "string" &&
error.message.match(/Access denied for user.*password/i)) {
@@ -15,5 +15,9 @@ type CreateNewUserParams = {
host?: string;
password?: string;
};
export declare function createNewSQLUser({ host, password, username, }: CreateNewUserParams): Promise<import("../../../types").PostInsertReturn | import("../../../types").PostInsertReturn[] | null>;
export declare function createNewSQLUser({ host, password, username, }: CreateNewUserParams): Promise<{
[k: string]: any;
} | {
[k: string]: any;
}[] | null>;
export {};