Updates
This commit is contained in:
parent
22f4372cbf
commit
daad62141e
@ -184,7 +184,7 @@ function addDbEntry(_a) {
|
|||||||
label: "queryValuesArray",
|
label: "queryValuesArray",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const newInsert = yield (0, conn_db_handler_1.default)(DB_CONN, query, queryValuesArray);
|
const newInsert = yield (0, conn_db_handler_1.default)(DB_CONN, query, queryValuesArray, debug);
|
||||||
if (debug) {
|
if (debug) {
|
||||||
(0, debug_log_1.default)({
|
(0, debug_log_1.default)({
|
||||||
log: newInsert,
|
log: newInsert,
|
||||||
|
@ -21,5 +21,5 @@ query?: QueryObject["query"] | QueryObject[],
|
|||||||
/**
|
/**
|
||||||
* Array of Values to Sanitize and Inject
|
* Array of Values to Sanitize and Inject
|
||||||
*/
|
*/
|
||||||
values?: QueryObject["values"]): Promise<Return<ReturnType>>;
|
values?: QueryObject["values"], debug?: boolean): Promise<Return<ReturnType>>;
|
||||||
export {};
|
export {};
|
||||||
|
27
dist/package-shared/utils/db/conn-db-handler.js
vendored
27
dist/package-shared/utils/db/conn-db-handler.js
vendored
@ -8,8 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.default = connDbHandler;
|
exports.default = connDbHandler;
|
||||||
|
const debug_log_1 = __importDefault(require("../logging/debug-log"));
|
||||||
/**
|
/**
|
||||||
* # Run Query From MySQL Connection
|
* # Run Query From MySQL Connection
|
||||||
* @description Run a query from a pre-existing MySQL/Mariadb Connection
|
* @description Run a query from a pre-existing MySQL/Mariadb Connection
|
||||||
@ -27,7 +31,7 @@ query,
|
|||||||
/**
|
/**
|
||||||
* Array of Values to Sanitize and Inject
|
* Array of Values to Sanitize and Inject
|
||||||
*/
|
*/
|
||||||
values) {
|
values, debug) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
try {
|
try {
|
||||||
@ -37,6 +41,13 @@ values) {
|
|||||||
throw new Error("Query String Required!");
|
throw new Error("Query String Required!");
|
||||||
if (typeof query == "string") {
|
if (typeof query == "string") {
|
||||||
const res = yield conn.query(trimQuery(query), values);
|
const res = yield conn.query(trimQuery(query), values);
|
||||||
|
if (debug) {
|
||||||
|
(0, debug_log_1.default)({
|
||||||
|
log: res,
|
||||||
|
addTime: true,
|
||||||
|
label: "res",
|
||||||
|
});
|
||||||
|
}
|
||||||
return JSON.parse(JSON.stringify(res));
|
return JSON.parse(JSON.stringify(res));
|
||||||
}
|
}
|
||||||
else if (typeof query == "object") {
|
else if (typeof query == "object") {
|
||||||
@ -45,6 +56,13 @@ values) {
|
|||||||
try {
|
try {
|
||||||
const queryObj = query[i];
|
const queryObj = query[i];
|
||||||
const queryObjRes = yield conn.query(trimQuery(queryObj.query), queryObj.values);
|
const queryObjRes = yield conn.query(trimQuery(queryObj.query), queryObj.values);
|
||||||
|
if (debug) {
|
||||||
|
(0, debug_log_1.default)({
|
||||||
|
log: queryObjRes,
|
||||||
|
addTime: true,
|
||||||
|
label: "queryObjRes",
|
||||||
|
});
|
||||||
|
}
|
||||||
resArray.push(JSON.parse(JSON.stringify(queryObjRes)));
|
resArray.push(JSON.parse(JSON.stringify(queryObjRes)));
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
@ -52,6 +70,13 @@ values) {
|
|||||||
resArray.push(null);
|
resArray.push(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (debug) {
|
||||||
|
(0, debug_log_1.default)({
|
||||||
|
log: resArray,
|
||||||
|
addTime: true,
|
||||||
|
label: "resArray",
|
||||||
|
});
|
||||||
|
}
|
||||||
return resArray;
|
return resArray;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -239,7 +239,12 @@ export default async function addDbEntry({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const newInsert = await connDbHandler(DB_CONN, query, queryValuesArray);
|
const newInsert = await connDbHandler(
|
||||||
|
DB_CONN,
|
||||||
|
query,
|
||||||
|
queryValuesArray,
|
||||||
|
debug
|
||||||
|
);
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
debugLog({
|
debugLog({
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { ServerlessMysql } from "serverless-mysql";
|
import { ServerlessMysql } from "serverless-mysql";
|
||||||
|
import debugLog from "../logging/debug-log";
|
||||||
|
|
||||||
type QueryObject = {
|
type QueryObject = {
|
||||||
query: string;
|
query: string;
|
||||||
@ -24,7 +25,8 @@ export default async function connDbHandler<ReturnType = any>(
|
|||||||
/**
|
/**
|
||||||
* Array of Values to Sanitize and Inject
|
* Array of Values to Sanitize and Inject
|
||||||
*/
|
*/
|
||||||
values?: QueryObject["values"]
|
values?: QueryObject["values"],
|
||||||
|
debug?: boolean
|
||||||
): Promise<Return<ReturnType>> {
|
): Promise<Return<ReturnType>> {
|
||||||
try {
|
try {
|
||||||
if (!conn) throw new Error("No Connection Found!");
|
if (!conn) throw new Error("No Connection Found!");
|
||||||
@ -32,6 +34,14 @@ export default async function connDbHandler<ReturnType = any>(
|
|||||||
|
|
||||||
if (typeof query == "string") {
|
if (typeof query == "string") {
|
||||||
const res = await conn.query(trimQuery(query), values);
|
const res = await conn.query(trimQuery(query), values);
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
debugLog({
|
||||||
|
log: res,
|
||||||
|
addTime: true,
|
||||||
|
label: "res",
|
||||||
|
});
|
||||||
|
}
|
||||||
return JSON.parse(JSON.stringify(res));
|
return JSON.parse(JSON.stringify(res));
|
||||||
} else if (typeof query == "object") {
|
} else if (typeof query == "object") {
|
||||||
const resArray = [];
|
const resArray = [];
|
||||||
@ -43,6 +53,15 @@ export default async function connDbHandler<ReturnType = any>(
|
|||||||
trimQuery(queryObj.query),
|
trimQuery(queryObj.query),
|
||||||
queryObj.values
|
queryObj.values
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
debugLog({
|
||||||
|
log: queryObjRes,
|
||||||
|
addTime: true,
|
||||||
|
label: "queryObjRes",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
resArray.push(JSON.parse(JSON.stringify(queryObjRes)));
|
resArray.push(JSON.parse(JSON.stringify(queryObjRes)));
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
global.ERROR_CALLBACK?.(
|
global.ERROR_CALLBACK?.(
|
||||||
@ -53,6 +72,14 @@ export default async function connDbHandler<ReturnType = any>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
debugLog({
|
||||||
|
log: resArray,
|
||||||
|
addTime: true,
|
||||||
|
label: "resArray",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return resArray as any;
|
return resArray as any;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/datasquirel",
|
"name": "@moduletrace/datasquirel",
|
||||||
"version": "4.4.6",
|
"version": "4.4.7",
|
||||||
"description": "Cloud-based SQL data management tool",
|
"description": "Cloud-based SQL data management tool",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
Loading…
Reference in New Issue
Block a user