allow to override default database config in new

this way we can temporarily allow to execute multiple statements
in one query.
This commit is contained in:
Wroclaw 2023-06-14 10:41:25 +02:00
parent 0705ed9018
commit bbe0c91d7e

View file

@ -11,7 +11,9 @@ const connectionOptions: mysql.ConnectionOptions = {
};
export const database =
await mysql.createConnection(connectionOptions) as Connection & { new: () => Promise<Connection> };
database.new = () => { return mysql.createConnection(connectionOptions); };
await mysql.createConnection(connectionOptions) as Connection & {
new: (localConnectionOptions: mysql.ConnectionOptions | undefined) => Promise<Connection>
};
database.new = (localConnectionOptions: mysql.ConnectionOptions | undefined) => { return mysql.createConnection({ ...localConnectionOptions, ...connectionOptions }); };
export type data<T> = [T[], mysql.FieldPacket[]];