runsv-mysql-pool

1.0.0 • Public • Published

runsv-mysql-pool

pipeline status coverage report

runsv service wrapper around the great mysql module.

Install

If you have already installed mysql

$ npm install runsv-mysql-pool

Otherwise

$ npm install mysql runsv-mysql-pool

mysql is a peer dependency of this module

Usage

Create a MySQL connection pool

const runsv = require('runsv')();
// Pool options. Same as https://www.npmjs.com/package/mysql#pool-options
const poolOptions = { /*...*/}
const createMySQLPoolService = require('runsv-mysql-pool');
const poolClientName = 'myPool';
const poolService = createMySQLPoolService(poolOptions, poolClientName);
runsv.addService(mysql);
runsv.start(function(err){
	const {myPool} = runsv.getClients();
	// myPool is the same object you will get with mysql.createPool(...)
	myPool.query('SELECT ...', function (err, rows) {
	/* ... */
	});
});
/* ... other application logic */

API

  • createMySQLPoolService(options, name='mysql') this function will create the service wrapper.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    0

Package Sidebar

Install

npm i runsv-mysql-pool

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

7.58 kB

Total Files

6

Last publish

Collaborators

  • p.revington