Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MysqlDriver

Organizes communication with MySQL DBMS.

Hierarchy

  • MysqlDriver

Implements

Index

Constructors

constructor

Properties

connection

connection: Connection

Connection used by driver.

Optional database

database: string

Master database used to perform all write queries.

isReplicated

isReplicated: boolean = false

Indicates if replication is enabled.

maxAliasLength

maxAliasLength: number = 63

Max length allowed by MySQL for aliases.

see

https://dev.mysql.com/doc/refman/5.5/en/identifiers.html

mysql

mysql: any

Mysql underlying library.

options

Connection options.

pool

pool: any

Connection pool. Used in non-replication mode.

poolCluster

poolCluster: any

Pool cluster used in replication mode.

spatialTypes

spatialTypes: ColumnType[] = ["geometry","point","linestring","polygon","multipoint","multilinestring","multipolygon","geometrycollection"]

Gets list of spatial column data types.

supportedDataTypes

supportedDataTypes: ColumnType[] = [// numeric types"bit","int","integer", // synonym for int"tinyint","smallint","mediumint","bigint","float","double","double precision", // synonym for double"real", // synonym for double"decimal","dec", // synonym for decimal"numeric", // synonym for decimal"fixed", // synonym for decimal"bool", // synonym for tinyint"boolean", // synonym for tinyint// date and time types"date","datetime","timestamp","time","year",// string types"char","nchar", // synonym for national char"national char","varchar","nvarchar", // synonym for national varchar"national varchar","blob","text","tinyblob","tinytext","mediumblob","mediumtext","longblob","longtext","enum","binary","varbinary",// json data type"json",// spatial data types"geometry","point","linestring","polygon","multipoint","multilinestring","multipolygon","geometrycollection"]

treeSupport

treeSupport: boolean = true

Indicates if tree tables are supported by this driver.

unsignedAndZerofillTypes

unsignedAndZerofillTypes: ColumnType[] = ["int","integer","smallint","tinyint","mediumint","bigint","decimal","dec","numeric","fixed","float","double","double precision","real"]

Gets list of column data types that supports UNSIGNED and ZEROFILL attributes.

withLengthColumnTypes

withLengthColumnTypes: ColumnType[] = ["char","varchar","nvarchar","binary","varbinary"]

Gets list of column data types that support length by a driver.

withPrecisionColumnTypes

withPrecisionColumnTypes: ColumnType[] = ["decimal","dec","numeric","fixed","float","double","double precision","real","time","datetime","timestamp"]

Gets list of column data types that support precision by a driver.

withScaleColumnTypes

withScaleColumnTypes: ColumnType[] = ["decimal","dec","numeric","fixed","float","double","double precision","real"]

Gets list of column data types that supports scale by a driver.

withWidthColumnTypes

withWidthColumnTypes: ColumnType[] = ["bit","tinyint","smallint","mediumint","int","integer","bigint"]

Gets list of column data types that support length by a driver.

Methods

afterConnect

  • afterConnect(): Promise<void>

buildTableName

  • buildTableName(tableName: string, schema?: string, database?: string): string
  • Build full table name with database name, schema name and table name. E.g. "myDB"."mySchema"."myTable"

    Parameters

    • tableName: string
    • Optional schema: string
    • Optional database: string

    Returns string

Protected compareDefaultValues

  • compareDefaultValues(columnMetadataValue: string, databaseValue: string): boolean
  • Checks if "DEFAULT" values in the column metadata and in the database are equal.

    Parameters

    • columnMetadataValue: string
    • databaseValue: string

    Returns boolean

connect

  • connect(): Promise<void>

Protected createConnectionOptions

createFullType

createGeneratedMap

  • createGeneratedMap(metadata: EntityMetadata, insertResult: any): any

createParameter

  • createParameter(parameterName: string, index: number): string

Protected createPool

  • createPool(connectionOptions: any): Promise<any>
  • Creates a new connection pool for a given database credentials.

    Parameters

    • connectionOptions: any

    Returns Promise<any>

createQueryRunner

createSchemaBuilder

disconnect

  • disconnect(): Promise<void>

escape

  • escape(columnName: string): string

escapeQueryWithParameters

findChangedColumns

getColumnLength

isReturningSqlSupported

  • isReturningSqlSupported(): boolean

isUUIDGenerationSupported

  • isUUIDGenerationSupported(): boolean

Protected loadDependencies

  • loadDependencies(): void

normalizeDefault

normalizeIsUnique

normalizeType

  • normalizeType(column: object): string
  • Creates a database type from a given column metadata.

    Parameters

    • column: object
      • Optional length?: number | string
      • Optional precision?: number | null
      • Optional scale?: number
      • type: ColumnType

    Returns string

obtainMasterConnection

  • obtainMasterConnection(): Promise<any>

obtainSlaveConnection

  • obtainSlaveConnection(): Promise<any>

Private prepareDbConnection

  • prepareDbConnection(connection: any): any
  • Attaches all required base handlers to a database connection, such as the unhandled error handler.

    Parameters

    • connection: any

    Returns any

prepareHydratedValue

  • prepareHydratedValue(value: any, columnMetadata: ColumnMetadata): any

preparePersistentValue

  • preparePersistentValue(value: any, columnMetadata: ColumnMetadata): any

Object literals

dataTypeDefaults

dataTypeDefaults: object

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.

bigint

bigint: object

width

width: number = 20

binary

binary: object

length

length: number = 1

bit

bit: object

width

width: number = 1

char

char: object

length

length: number = 1

datetime

datetime: object

precision

precision: number = 0

dec

dec: object

precision

precision: number = 10

scale

scale: number = 0

decimal

decimal: object

precision

precision: number = 10

scale

scale: number = 0

double

double: object

precision

precision: number = 22

fixed

fixed: object

precision

precision: number = 10

scale

scale: number = 0

float

float: object

precision

precision: number = 12

int

int: object

width

width: number = 11

integer

integer: object

width

width: number = 11

mediumint

mediumint: object

width

width: number = 9

national varchar

national varchar: object

length

length: number = 255

numeric

numeric: object

precision

precision: number = 10

scale

scale: number = 0

nvarchar

nvarchar: object

length

length: number = 255

smallint

smallint: object

width

width: number = 6

time

time: object

precision

precision: number = 0

timestamp

timestamp: object

precision

precision: number = 0

tinyint

tinyint: object

width

width: number = 4

varbinary

varbinary: object

length

length: number = 255

varchar

varchar: object

length

length: number = 255

mappedDataTypes

mappedDataTypes: object

ORM has special columns and we need to know what database column types should be for those columns. Column types are driver dependant.

cacheDuration

cacheDuration: "int" = "int"

cacheId

cacheId: "int" = "int"

cacheIdentifier

cacheIdentifier: "varchar" = "varchar"

cacheQuery

cacheQuery: "text" = "text"

cacheResult

cacheResult: "text" = "text"

cacheTime

cacheTime: "bigint" = "bigint"

createDate

createDate: "datetime" = "datetime"

createDateDefault

createDateDefault: string = "CURRENT_TIMESTAMP(6)"

createDatePrecision

createDatePrecision: number = 6

metadataDatabase

metadataDatabase: "varchar" = "varchar"

metadataName

metadataName: "varchar" = "varchar"

metadataSchema

metadataSchema: "varchar" = "varchar"

metadataTable

metadataTable: "varchar" = "varchar"

metadataType

metadataType: "varchar" = "varchar"

metadataValue

metadataValue: "text" = "text"

migrationId

migrationId: "int" = "int"

migrationName

migrationName: "varchar" = "varchar"

migrationTimestamp

migrationTimestamp: "bigint" = "bigint"

treeLevel

treeLevel: "int" = "int"

updateDate

updateDate: "datetime" = "datetime"

updateDateDefault

updateDateDefault: string = "CURRENT_TIMESTAMP(6)"

updateDatePrecision

updateDatePrecision: number = 6

version

version: "int" = "int"

Generated using TypeDoc