Skip to content

Commit

Permalink
chore(docs): readme updated
Browse files Browse the repository at this point in the history
  • Loading branch information
hsynlms committed Jul 29, 2021
1 parent 57468b4 commit ff1d3d0
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,40 @@ $ npm install sequelize-fastify
```

## Usage
Please find an usage of MSSQL example of the plugin below.

```js
fastify.register(
require('sequelize-fastify'),
{
instance: 'db',
sequelizeOptions: {
dialect: 'DIALECT_NAME', /* one of 'mysql' | 'mariadb' | 'postgres' | 'mssql' */
database: 'DATABASE_NAME',
dialect: 'mssql',
host: 'DATABASE_HOST_OR_SERVER',
username: 'DATABASE_USER_NAME',
password: 'DATABASE_USER_PASSWORD',
port: DATABASE_PORT,
dialectOptions: {
encrypt: true,
trustedConnection: true,
requestTimeout: 30000 // 30 seconds
options: {
host: 'DATABASE_HOST_OR_SERVER',
port: 'DATABASE_PORT'
}
}
}
)
.ready(async () => {
try {
// first connection as test
const result = await fastify.db.authenticate()

console.log(
chalk.green('Database connection is successfully established.')
)

fastify.close()
} catch(err) {
console.log(
chalk.red(`Connection could not established: ${err}`)
)
}
})
.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
Expand Down

0 comments on commit ff1d3d0

Please sign in to comment.