# sequelize-fastify

> a Sequelize plugin for Fastify.

Latest version **2.0.0** (published 2022-06-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install sequelize-fastify
pnpm add sequelize-fastify
yarn add sequelize-fastify
bun add sequelize-fastify
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2022-06-10 |
| First published | 2020-06-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | ^14.17.0 \|\| >=16.0.0 |
| Dependencies | 2 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Huseyin ELMAS |
| Maintainers | hsynlms |
| Keywords | sequelize, fastify, fastify-plugin, sqlite, mysql, postgres, mssql |

## Links

- npm: https://www.npmjs.com/package/sequelize-fastify
- Repository: https://github.com/hsynlms/sequelize-fastify
- Homepage: https://github.com/hsynlms/sequelize-fastify#readme
- Issues: https://github.com/hsynlms/sequelize-fastify/issues
- npm.io page: https://npm.io/package/sequelize-fastify

## Dependencies (2)

- [sequelize](https://npm.io/package/sequelize.md) ^6.20.1
- [fastify-plugin](https://npm.io/package/fastify-plugin.md) ^3.0.1

## Alternatives

- [@libsql/sqlite3](https://npm.io/package/@libsql/sqlite3.md) — 39.8K weekly downloads
- [@fortemi/core](https://npm.io/package/@fortemi/core.md) — 461 weekly downloads
- [cdb-converter](https://npm.io/package/cdb-converter.md) — 341 weekly downloads
- [@uplo/adapter-prisma](https://npm.io/package/@uplo/adapter-prisma.md) — 75 weekly downloads
- [typeorm-aios](https://npm.io/package/typeorm-aios.md) — 30 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2022-06-10
- 1.1.0 — 2022-06-10
- 1.0.9 — 2021-07-29
- 1.0.8 — 2021-07-29
- 1.0.7 — 2021-05-16
- 1.0.6 — 2021-05-01
- 1.0.5 — 2020-11-07
- 1.0.4 — 2020-10-13
- 1.0.3 — 2020-07-14
- 1.0.2 — 2020-06-13
- 1.0.1 — 2020-06-13
- 1.0.0 — 2020-06-13

## README

# sequelize-fastify
> A [Sequelize](https://sequelize.org/) plugin for [Fastify](https://github.com/fastify/fastify).

[![Downloads](https://img.shields.io/npm/dm/sequelize-fastify.svg)](https://npmjs.com/sequelize-fastify)
[![install size](https://packagephobia.com/badge?p=sequelize-fastify)](https://packagephobia.com/result?p=sequelize-fastify)

**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](https://github.com/sequelize/sequelize) for more information and developer documentation.

## Installation
```
$ 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](https://sequelize.org/master/class/lib/sequelize.js~Sequelize.html#instance-constructor-constructor) doc. |

---
_Source: https://npm.io/package/sequelize-fastify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
