Updates
This commit is contained in:
+2
-2
@@ -13,11 +13,11 @@ export default function connDbHandler<ReturnType = any>(
|
||||
/**
|
||||
* ServerlessMySQL Connection Object
|
||||
*/
|
||||
conn: ServerlessMysql,
|
||||
conn?: ServerlessMysql,
|
||||
/**
|
||||
* String Or `QueryObject` Array
|
||||
*/
|
||||
query: QueryObject["query"] | QueryObject[],
|
||||
query?: QueryObject["query"] | QueryObject[],
|
||||
/**
|
||||
* Array of Values to Sanitize and Inject
|
||||
*/
|
||||
|
||||
+7
-1
@@ -30,6 +30,10 @@ query,
|
||||
values) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
if (!conn)
|
||||
throw new Error("No Connection Found!");
|
||||
if (!query)
|
||||
throw new Error("Query String Required!");
|
||||
if (typeof query == "string") {
|
||||
const res = yield conn.query(trimQuery(query), values);
|
||||
return JSON.parse(JSON.stringify(res));
|
||||
@@ -43,6 +47,7 @@ values) {
|
||||
resArray.push(JSON.parse(JSON.stringify(queryObjRes)));
|
||||
}
|
||||
catch (error) {
|
||||
console.log(`connDbHandler Query Error: ${error.message}`);
|
||||
resArray.push(null);
|
||||
}
|
||||
}
|
||||
@@ -53,10 +58,11 @@ values) {
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.log(`connDbHandler Error: ${error.message}`);
|
||||
return null;
|
||||
}
|
||||
finally {
|
||||
conn.end();
|
||||
conn === null || conn === void 0 ? void 0 : conn.end();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user