Options of the Sequelize constructor used by the core library.

See Options for the full list of options, including those dialect-specific.

interface SequelizeCoreOptions<Dialect> {
    benchmark?: boolean;
    databaseVersion?: string;
    defaultTimestampPrecision?: null | number;
    defaultTransactionNestMode?: TransactionNestMode;
    define?: Omit<ModelOptions<Model<any, any>>, "name" | "modelName" | "tableName">;
    dialect: "mysql" | "postgres" | "sqlite3" | "mariadb" | "mssql" | "db2" | "snowflake" | "ibmi" | Class<Dialect>;
    disableClsTransactions?: boolean;
    hooks?: Partial<SequelizeHooks<Dialect>>;
    isolationLevel?: IsolationLevel;
    keepDefaultTimezone?: boolean;
    logQueryParameters?: boolean;
    logging?: false | ((sql, timing?) => void);
    minifyAliases?: boolean;
    models?: ModelStatic[];
    noTypeValidation?: boolean;
    nullJsonStringification?: "explicit" | "json" | "sql";
    omitNull?: boolean;
    pool?: PoolOptions<Dialect>;
    prependSearchPath?: boolean;
    query?: QueryOptions;
    quoteIdentifiers?: boolean;
    replication?: false | Nullish | ReplicationOptions<Dialect>;
    retry?: Options;
    schema?: string;
    set?: DefaultSetOptions;
    sync?: SyncOptions;
    timezone?: string;
    transactionType?: TransactionType;
    url?: string;
}

Type Parameters

Hierarchy (view full)

Properties

benchmark?: boolean

Pass query execution time in milliseconds as second argument to logging function (options.logging).

databaseVersion?: string

The version of the Database Sequelize will connect to. If unspecified, or set to 0, Sequelize will retrieve it during its first connection to the Database.

defaultTimestampPrecision?: null | number

The precision for the createdAt/updatedAt/deletedAt DATETIME columns that Sequelize adds to models. Can be a number between 0 and 6, or null to use the default precision of the database. Defaults to 6.

Default

6
defaultTransactionNestMode?: TransactionNestMode

How nested transaction blocks behave by default. See ManagedTransactionOptions#nestMode for more information.

Default

TransactionNestMode.reuse
define?: Omit<ModelOptions<Model<any, any>>, "name" | "modelName" | "tableName">

Default options for model definitions. See Model.init.

dialect: "mysql" | "postgres" | "sqlite3" | "mariadb" | "mssql" | "db2" | "snowflake" | "ibmi" | Class<Dialect>

The dialect of the database you are connecting to. Either the name of the dialect, or a dialect class.

disableClsTransactions?: boolean

Disable the use of AsyncLocalStorage to automatically pass transactions started by Sequelize#transaction. You will need to pass transactions around manually if you disable this.

Sets global permanent hooks.

isolationLevel?: IsolationLevel

Set the default transaction isolation level. If not set, does not change the database's default transaction isolation level.

keepDefaultTimezone?: boolean

A flag that defines if the default timezone is used to convert dates from the database.

Default

false
logQueryParameters?: boolean

Set to true to show bind parameters in log.

Default

false
logging?: false | ((sql, timing?) => void)

A function that gets executed while running the query to log the sql.

Type declaration

    • (sql, timing?): void
    • Parameters

      • sql: string
      • Optional timing: number

      Returns void

minifyAliases?: boolean

Set to true to automatically minify aliases generated by sequelize. Mostly useful to circumvent the POSTGRES alias limit of 64 characters.

Default

false
models?: ModelStatic[]

A list of models to load and init.

This option is only useful if you created your models using decorators. Models created using Model.init or Sequelize#define don't need to be specified in this option.

Use importModels to load models dynamically:

Example

import { User } from './models/user.js';

new Sequelize({
models: [User],
});

Example

new Sequelize({
models: await importModels(__dirname + '/*.model.ts'),
});
noTypeValidation?: boolean

Disable built in type validators on insert and update, e.g. don't validate that arguments passed to integer fields are integer-like.

Default

false
nullJsonStringification?: "explicit" | "json" | "sql"

When representing the JavaScript null primitive in a JSON column, Sequelize can use either the SQL NULL value, or a JSON 'null'.

Set this to "json" if you want the null to be stored as a JSON 'null'. Set this to "sql" if you want the null to be stored as the SQL NULL value. Set this to "explicit" if you don't want Sequelize to make any assumptions. This means that you won't be able to use the JavaScript null primitive as the top level value of a JSON column, you will have to use SQL_NULL or JSON_NULL instead.

This only impacts serialization when inserting or updating values. Comparing always requires to be explicit.

Read more: https://sequelize.org/docs/v7/querying/json/

Default

json
omitNull?: boolean

A flag that defines if null values should be passed to SQL queries or not.

Default

false

Connection pool options

prependSearchPath?: boolean
query?: QueryOptions

Default options for sequelize.query

quoteIdentifiers?: boolean

Set to false to make table names and attributes case-insensitive on Postgres and skip double quoting of them.

Default

true
replication?: false | Nullish | ReplicationOptions<Dialect>

Use read / write replication. To enable replication, pass an object, with two properties, read and write. Write should be an object (a single server for handling writes), and read an array of object (several servers to handle reads). Each read/write server can have the following properties: host, port, username, password, database. Connection strings can be used instead of objects.

Default

false
retry?: Options
schema?: string

If defined, the connection will use the provided schema instead of the default ("public").

Default options for sequelize.set

Default options for sequelize.sync

timezone?: string

The timezone used when converting a date from the database into a JavaScript date. The timezone is also used to SET TIMEZONE when connecting to the server, to ensure that the result of NOW, CURRENT_TIMESTAMP and other time related functions have in the right timezone. For best cross platform performance use the format +/-HH:MM. Will also accept string versions of timezones supported by Intl.Locale (e.g. 'America/Los_Angeles'); this is useful to capture daylight savings time changes.

Default

'+00:00'
transactionType?: TransactionType

Set the default transaction type. See Sequelize.Transaction.TYPES for possible options. Sqlite only.

Default

'DEFERRED'
url?: string

The connection URL. If other connection options are set, they will override the values set in this URL.