1.3.2 • Published 6 months ago

exframe-sql v1.3.2

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
6 months ago

exframe SQL Module

A wrapper around sequelize/potentially other sql connectors to provide sql database connection for the Harmony Framework.

By default calling the base init method will currently return an instance of a Sequelize connector/driver.

Features

  • Multi-driver supported sql connection
  • Exframe-Service Graceful Shutdown

Use

const db = require('exframe-sql')

Full Example

const db = require('exframe-sql')
const logger = require('exframe-logger').create(process.env.LOGSENE_TOKEN || 'token');

const { connection } = db.init({
  logger,
  name: 'test',
  username: 'username',
  password: 'password',
  port: 1533,
  host: 'localhost',
});

await connection.query('SELECT 1+1');

Properties

  • Drivers List of available drivers
  • SqlConnector SqlConnector class for customization
  • Sequelize Core Sequelize Library export

Methods

init()

Syntax

db.init({ logger, username: 'test' });

Parameter Values

Returns

SqlConnector instance

connector.check()
const {status, message} = await connection.check()

Simple health check method to check the status of the database connection

connector.connect()
await connector.connect()
connector.close()
await connector.close()

Connector Properties

PropertyTypeCan be null?Details
connectionobjectyesThe underlying driver connection instance (e.g. a sequelize connection)
namestringnoconnection instance name
orderstringnoexframe service order

Tests

npm run test
1.3.2

6 months ago

1.3.1

7 months ago

1.3.0

8 months ago

1.2.6

9 months ago

1.2.5

1 year ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago