35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { DsqlConnectionParam, DSQLErrorObject } from "../../types";
|
|
import mariadb, { ConnectionConfig } from "mariadb";
|
|
export type ConnDBHandlerQueryObject = {
|
|
query: string;
|
|
values?: (string | number | undefined)[];
|
|
};
|
|
type Return<ReturnType = any> = ReturnType | ReturnType[] | null | {
|
|
error?: string;
|
|
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>({ conn, debug, query, values, dsqlConnOpts, }: ConnectionDbHandlerParams): Promise<Return<ReturnType>>;
|
|
export {};
|