Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface MysqlConnectionOptions

MySQL specific connection options.

see

https://github.com/mysqljs/mysql#connection-options

Hierarchy

Index

Properties

Optional acquireTimeout

acquireTimeout: number

The milliseconds before a timeout doccurs during the initial connection to the MySQL server. (Default: 10000) This difference between connectTimeout and acquireTimeout is subtle and is described in the mysqljs/mysql docs https://github.com/mysqljs/mysql/tree/master#pool-options

Optional bigNumberStrings

bigNumberStrings: boolean

Enabling both supportBigNumbers and bigNumberStrings forces big numbers (BIGINT and DECIMAL columns) to be always returned as JavaScript String objects (Default: false). Enabling supportBigNumbers but leaving bigNumberStrings disabled will return big numbers as String objects only when they cannot be accurately represented with JavaScript Number objects (which happens when they exceed the [-2^53, +2^53] range), otherwise they will be returned as Number objects. This option is ignored if supportBigNumbers is disabled.

Optional cache

cache: boolean | object

Allows to setup cache options.

Optional charset

charset: string

The charset for the connection. This is called "collation" in the SQL-level of MySQL (like utf8_general_ci). If a SQL-level charset is specified (like utf8mb4) then the default collation for that charset is used. Default: 'UTF8_GENERAL_CI'

Optional cli

cli: object

CLI settings.

Type declaration

  • Optional entitiesDir?: string

    Directory where entities should be created by default.

  • Optional migrationsDir?: string

    Directory where migrations should be created by default.

  • Optional subscribersDir?: string

    Directory where subscribers should be created by default.

Optional connectTimeout

connectTimeout: number

The milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10000)

Optional database

database: string

Database name to connect to.

Optional dateStrings

dateStrings: boolean | string[]

Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then inflated into JavaScript Date objects. Can be true/false or an array of type names to keep as strings.

Optional debug

debug: boolean | string[]

Prints protocol details to stdout. Can be true/false or an array of packet type names that should be printed. (Default: false)

Optional dropSchema

dropSchema: boolean

Drops the schema each time connection is being established. Be careful with this option and don't use this in production - otherwise you'll lose all production data. This option is useful during debug and development.

Optional entities

entities: (string | Function | EntitySchema<any>)[]

Entities to be loaded for this connection. Accepts both entity classes and directories where from entities need to be loaded. Directories support glob patterns.

Optional entityPrefix

entityPrefix: string

Prefix to use on all tables (collections) of this connection in the database.

Optional extra

extra: any

Extra connection options to be passed to the underlying driver.

todo: deprecate this and move all database-specific types into hts own connection options object.

Optional flags

flags: string[]

List of connection flags to use other than the default ones. It is also possible to blacklist default ones. For more information, check https://github.com/mysqljs/mysql#connection-flags.

Optional host

host: string

Database host.

Optional insecureAuth

insecureAuth: boolean

Allow connecting to MySQL instances that ask for the old (insecure) authentication method. (Default: false)

Optional logger

logger: "advanced-console" | "simple-console" | "file" | "debug" | Logger

Logger instance used to log queries and events in the ORM.

Optional logging

logging: LoggerOptions

Logging options.

Optional maxQueryExecutionTime

maxQueryExecutionTime: number

Maximum number of milliseconds query should be executed before logger log a warning.

Optional migrations

migrations: (string | Function)[]

Migrations to be loaded for this connection. Accepts both migration classes and directories where from migrations need to be loaded. Directories support glob patterns.

Optional migrationsRun

migrationsRun: boolean

Indicates if migrations should be auto run on every application launch. Alternative to it, you can use CLI and run migrations:run command.

Optional migrationsTableName

migrationsTableName: string

Migrations table name, in case of different name from "migrations". Accepts single string name.

Optional multipleStatements

multipleStatements: boolean

Allow multiple mysql statements per query. Be careful with this, it could increase the scope of SQL injection attacks. (Default: false)

Optional name

name: string

Connection name. If connection name is not given then it will be called "default". Different connections must have different names.

Optional namingStrategy

namingStrategy: NamingStrategyInterface

Naming strategy to be used to name tables and columns in the database.

Optional password

password: string

Database password.

Optional port

port: number

Database host port.

Optional replication

replication: object

Replication setup.

Type declaration

  • Optional canRetry?: boolean

    If true, PoolCluster will attempt to reconnect when connection fails. (Default: true)

  • master: MysqlConnectionCredentialsOptions

    Master server used by orm to perform writes.

  • Optional removeNodeErrorCount?: number

    If connection fails, node's errorCount increases. When errorCount is greater than removeNodeErrorCount, remove a node in the PoolCluster. (Default: 5)

  • Optional restoreNodeTimeout?: number

    If connection fails, specifies the number of milliseconds before another connection attempt will be made. If set to 0, then node will be removed instead and never re-used. (Default: 0)

  • Optional selector?: "RR" | "RANDOM" | "ORDER"

    Determines how slaves are selected: RR: Select one alternately (Round-Robin). RANDOM: Select the node by random function. ORDER: Select the first node available unconditionally.

  • slaves: MysqlConnectionCredentialsOptions[]

    List of read-from severs (slaves).

Optional ssl

ssl: any

Object with ssl parameters or a string containing name of ssl profile.

Optional subscribers

subscribers: (string | Function)[]

Subscribers to be loaded for this connection. Accepts both subscriber classes and directories where from subscribers need to be loaded. Directories support glob patterns.

Optional supportBigNumbers

supportBigNumbers: boolean

When dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option (Default: false)

Optional synchronize

synchronize: boolean

Indicates if database schema should be auto created on every application launch. Be careful with this option and don't use this in production - otherwise you can lose production data. This option is useful during debug and development. Alternative to it, you can use CLI and run schema:sync command.

Note that for MongoDB database it does not create schema, because MongoDB is schemaless. Instead, it syncs just by creating indices.

Optional timezone

timezone: string

The timezone configured on the MySQL server. This is used to type cast server date/time values to JavaScript Date object and vice versa. This can be 'local', 'Z', or an offset in the form +HH:MM or -HH:MM. (Default: 'local')

Optional trace

trace: boolean

Generates stack traces on Error to include call site of library entrance ("long stack traces"). Slight performance penalty for most calls. (Default: true)

type

type: "mysql" | "mariadb"

Database type.

Optional url

url: string

Connection url where perform connection to.

Optional username

username: string

Database username.

Generated using TypeDoc