First version without typescript errors
This commit is contained in:
+2
-15
@@ -5,9 +5,6 @@ import grabDBConnection from "./grab-db-connection";
|
||||
type Param = {
|
||||
query: string;
|
||||
values?: string[] | object;
|
||||
noErrorLogs?: boolean;
|
||||
database?: string;
|
||||
tableSchema?: BUN_MARIADB_TableSchemaType;
|
||||
config?: ConnectionConfig;
|
||||
};
|
||||
|
||||
@@ -17,18 +14,12 @@ type Param = {
|
||||
*/
|
||||
export default async function dbHandler<
|
||||
T extends { [k: string]: any } = { [k: string]: any },
|
||||
>({
|
||||
query,
|
||||
values,
|
||||
noErrorLogs,
|
||||
database,
|
||||
config,
|
||||
}: Param): Promise<DBResponseObject> {
|
||||
>({ query, values, config }: Param): Promise<DBResponseObject> {
|
||||
let CONNECTION: Connection | undefined;
|
||||
let results: T | null = null;
|
||||
|
||||
try {
|
||||
CONNECTION = await grabDBConnection({ database, config });
|
||||
CONNECTION = await grabDBConnection({ config });
|
||||
|
||||
if (query && values) {
|
||||
const queryResults = await CONNECTION.query(query, values);
|
||||
@@ -46,10 +37,6 @@ export default async function dbHandler<
|
||||
throw new Error("Authentication Failed!");
|
||||
}
|
||||
|
||||
if (!noErrorLogs) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
results = null;
|
||||
} finally {
|
||||
await CONNECTION?.end();
|
||||
|
||||
Reference in New Issue
Block a user