UNPKG

@kwaeri/mysql-database-driver

Version:

The @kwaeri/mysql-database-driver component of the @kwaer/node-kit application platform.

39 lines (38 loc) 1.43 kB
/** * SPDX-PackageName: kwaeri/mysql-database-driver * SPDX-PackageVersion: 0.6.1 * SPDX-FileCopyrightText: © 2014 - 2022 Richard Winters <kirvedx@gmail.com> and contributors * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR MIT */ import * as mysql from 'mysql2'; import { DatabaseDriver, DriverConnectionBits, QueryResult } from '@kwaeri/database-driver'; /** * The MySQLDriver implements the DatabaseDriver for MySQL provider */ export declare class MySQLDriver extends DatabaseDriver { /** * @var { mysql.Pool } pool */ pool: mysql.Pool; /** * Class constructor */ constructor(config: DriverConnectionBits); /** * This overload executes a prepared statement using mysql2. * * @param { string } query The placeholder (`?`) possessed query string to be executed. * @param { any[] } bits The optional bits to supplement when composing a prepared statement (one for each placeholder). * * @returns { Promise<QueryPromise> } A promise of a {@link QueryResult} * <br /> * **Example**: * ```typescript * // An example using prepared statements: * const dbo = new MySQLDriver( connection ); * * const { rows, fields } = await dbo.query( "select * from table where `first_name`=? and `age`>=?;", ["Richard", 35] ); * ``` */ query<T extends QueryResult>(query: string, bits?: any[]): Promise<T>; }