Updates
This commit is contained in:
+18
-14
@@ -1,4 +1,4 @@
|
||||
import { DSQLErrorObject } from "../../types";
|
||||
import { DsqlConnectionParam, DSQLErrorObject } from "../../types";
|
||||
import mariadb, { ConnectionConfig } from "mariadb";
|
||||
export type ConnDBHandlerQueryObject = {
|
||||
query: string;
|
||||
@@ -9,22 +9,26 @@ type Return<ReturnType = any> = ReturnType | ReturnType[] | null | {
|
||||
errors?: DSQLErrorObject[];
|
||||
config?: ConnectionConfig;
|
||||
};
|
||||
export type ConnectionDbHandlerParams = {
|
||||
/**
|
||||
* MariaDB Connection
|
||||
*/
|
||||
conn?: mariadb.Connection | null;
|
||||
/**
|
||||
* String Or `ConnDBHandlerQueryObject` Array
|
||||
*/
|
||||
query?: ConnDBHandlerQueryObject["query"] | ConnDBHandlerQueryObject[];
|
||||
/**
|
||||
* Array of Values to Sanitize and Inject
|
||||
*/
|
||||
values?: ConnDBHandlerQueryObject["values"];
|
||||
debug?: boolean;
|
||||
dsqlConnOpts?: DsqlConnectionParam;
|
||||
};
|
||||
/**
|
||||
* # Run Query From MySQL Connection
|
||||
* @description Run a query from a pre-existing MySQL/Mariadb Connection
|
||||
* setup with `serverless-mysql` npm module
|
||||
*/
|
||||
export default function connDbHandler<ReturnType = any>(
|
||||
/**
|
||||
* MariaDB Connection
|
||||
*/
|
||||
conn?: mariadb.Connection | null,
|
||||
/**
|
||||
* String Or `ConnDBHandlerQueryObject` Array
|
||||
*/
|
||||
query?: ConnDBHandlerQueryObject["query"] | ConnDBHandlerQueryObject[],
|
||||
/**
|
||||
* Array of Values to Sanitize and Inject
|
||||
*/
|
||||
values?: ConnDBHandlerQueryObject["values"], debug?: boolean): Promise<Return<ReturnType>>;
|
||||
export default function connDbHandler<ReturnType = any>({ conn, debug, query, values, dsqlConnOpts, }: ConnectionDbHandlerParams): Promise<Return<ReturnType>>;
|
||||
export {};
|
||||
|
||||
+3
-15
@@ -20,21 +20,9 @@ const grab_dsql_connection_1 = __importDefault(require("../grab-dsql-connection"
|
||||
* @description Run a query from a pre-existing MySQL/Mariadb Connection
|
||||
* setup with `serverless-mysql` npm module
|
||||
*/
|
||||
function connDbHandler(
|
||||
/**
|
||||
* MariaDB Connection
|
||||
*/
|
||||
conn,
|
||||
/**
|
||||
* String Or `ConnDBHandlerQueryObject` Array
|
||||
*/
|
||||
query,
|
||||
/**
|
||||
* Array of Values to Sanitize and Inject
|
||||
*/
|
||||
values, debug) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const finalConnection = conn || (yield (0, grab_dsql_connection_1.default)());
|
||||
function connDbHandler(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ conn, debug, query, values, dsqlConnOpts, }) {
|
||||
const finalConnection = conn || (yield (0, grab_dsql_connection_1.default)(dsqlConnOpts));
|
||||
try {
|
||||
if (!finalConnection)
|
||||
throw new Error("No Connection Found!");
|
||||
|
||||
Reference in New Issue
Block a user