a Sequelize plugin for Fastify.
npm install sequelize-fastify

Note: Fastify v4 support is shipped with v2.0.0.
Supported Sequelize versions:
- v6.x
Please check official website for more information and developer documentation.
$ npm install sequelize-fastify --save
`Usage
`js
const sequelizeFastify = require('sequelize-fastify')await fastify.register(
sequelizeFastify,
{
instance: 'db',
sequelizeOptions: {
dialect: 'DIALECT_NAME', / one of 'mysql' | 'mariadb' | 'postgres' | 'mssql' /
database: 'DATABASE_NAME',
username: 'DATABASE_USER_NAME',
password: 'DATABASE_USER_PASSWORD',
options: {
host: 'DATABASE_HOST_OR_SERVER',
port: 'DATABASE_PORT'
}
}
}
)
.ready(async () => {
try {
// first connection
const result = await fastify.db.authenticate()
console.log(
chalk.green('Database connection is successfully established.')
)
} catch(err) {
console.log(
chalk.red(
Connection could not established: ${err})
)
} finally {
fastify.close()
}
})
`Options
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| instance | string | sequelize | A decorator instance name which will be available anywhere in the fastify server. |
| sequelizeOptions | object | {}` | Sequelize configuration object which will be passed to Sequelize instance while creating. Please see API Reference doc. |