2.0.0 • Published 2 years ago

sequelize-fastify v2.0.0

Weekly downloads
25
License
MIT
Repository
github
Last release
2 years ago

sequelize-fastify

A Sequelize plugin for Fastify.

Downloads install size

Note: Fastify v4 support is shipped with v2.0.0.

Supported Sequelize versions:

  • v6.x

What is Sequelize?

Sequelize is a promise-based Node.js ORM for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server. It features solid transaction support, relations, eager and lazy loading, read replication and more.

Please check official website for more information and developer documentation.

Installation

$ npm install sequelize-fastify --save

Usage

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

NameTypeDefaultDescription
instancestringsequelizeA decorator instance name which will be available anywhere in the fastify server.
sequelizeOptionsobject{}Sequelize configuration object which will be passed to Sequelize instance while creating. Please see API Reference doc.
1.1.0

2 years ago

2.0.0

2 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago