import { Driver } from "../Driver"; import { MysqlQueryRunner } from "./MysqlQueryRunner"; import { ObjectLiteral } from "../../common/ObjectLiteral"; import { ColumnMetadata } from "../../metadata/ColumnMetadata"; import { Connection } from "../../connection/Connection"; import { RdbmsSchemaBuilder } from "../../schema-builder/RdbmsSchemaBuilder"; import { MysqlConnectionOptions } from "./MysqlConnectionOptions"; import { MappedColumnTypes } from "../types/MappedColumnTypes"; import { ColumnType } from "../types/ColumnTypes"; import { DataTypeDefaults } from "../types/DataTypeDefaults"; import { ColumnSchema } from "../../schema-builder/schema/ColumnSchema"; import { MysqlConnectionCredentialsOptions } from "./MysqlConnectionCredentialsOptions"; /** * Organizes communication with MySQL DBMS. */ export declare class MysqlDriver implements Driver { /** * Connection used by driver. */ connection: Connection; /** * Mysql underlying library. */ mysql: any; /** * Connection pool. * Used in non-replication mode. */ pool: any; /** * Pool cluster used in replication mode. */ poolCluster: any; /** * Connection options. */ options: MysqlConnectionOptions; /** * Master database used to perform all write queries. */ database?: string; /** * Indicates if replication is enabled. */ isReplicated: boolean; /** * Indicates if tree tables are supported by this driver. */ treeSupport: boolean; /** * Gets list of supported column data types by a driver. * * @see https://www.tutorialspoint.com/mysql/mysql-data-types.htm * @see https://dev.mysql.com/doc/refman/5.7/en/data-types.html */ supportedDataTypes: ColumnType[]; /** * ORM has special columns and we need to know what database column types should be for those columns. * Column types are driver dependant. */ mappedDataTypes: MappedColumnTypes; /** * Default values of length, precision and scale depends on column data type. * Used in the cases when length/precision/scale is not specified by user. */ dataTypeDefaults: DataTypeDefaults; constructor(connection: Connection); /** * Performs connection to the database. */ connect(): Promise; /** * Makes any action after connection (e.g. create extensions in Postgres driver). */ afterConnect(): Promise; /** * Closes connection with the database. */ disconnect(): Promise; /** * Creates a schema builder used to build and sync a schema. */ createSchemaBuilder(): RdbmsSchemaBuilder; /** * Creates a query runner used to execute database queries. */ createQueryRunner(mode?: "master" | "slave"): MysqlQueryRunner; /** * Replaces parameters in the given sql with special escaping character * and an array of parameter names to be passed to a query. */ escapeQueryWithParameters(sql: string, parameters: ObjectLiteral): [string, any[]]; /** * Escapes a column name. */ escape(columnName: string): string; /** * Prepares given value to a value to be persisted, based on its column type and metadata. */ preparePersistentValue(value: any, columnMetadata: ColumnMetadata): any; /** * Prepares given value to a value to be persisted, based on its column type or metadata. */ prepareHydratedValue(value: any, columnMetadata: ColumnMetadata): any; /** * Creates a database type from a given column metadata. */ normalizeType(column: { type: ColumnType; length?: number; precision?: number; scale?: number; }): string; /** * Normalizes "default" value of the column. */ normalizeDefault(column: ColumnMetadata): string; createFullType(column: ColumnSchema): string; /** * Obtains a new database connection to a master server. * Used for replication. * If replication is not setup then returns default connection's database connection. */ obtainMasterConnection(): Promise; /** * Obtains a new database connection to a slave server. * Used for replication. * If replication is not setup then returns master (default) connection's database connection. */ obtainSlaveConnection(): Promise; /** * Loads all driver dependencies. */ protected loadDependencies(): void; /** * Creates a new connection pool for a given database credentials. */ protected createConnectionOptions(options: MysqlConnectionOptions, credentials: MysqlConnectionCredentialsOptions): Promise; /** * Creates a new connection pool for a given database credentials. */ protected createPool(connectionOptions: any): Promise; }