0.0.6 • Published 7 years ago

engined-mysql v0.0.6

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

engined-mysql

MySQL agent service for engined, which is based on node-mysql2.

NPM

Installation

Install via NPM:

npm install engined-mysql

Usage

start mysql agent service in engined, see example below:

const { Manager } = require('engined');
const MySQLService = require('engined-mysql');

const MySQLDB = MySQLService({
	agentName: 'MyDB', // optional: default to 'default' if not set
	uri: 'mysql://localhost:3306/mydb'
});

const main = async () => {

	// Create manager
	let serviceManager = new Manager({ verbose: true });

	// Adding agent to manager
	serviceManager.add('MySQLDB', MySQLDB);

	// Start all services
	await serviceManager.startAll();
};

main();

Access MySQL Database

Pretty easy to get agent from context query database by node-mysql way.

let agent = this.getContext('MySQL').getAgent('MyDB');

// Querying
let ret = await agent.query('SELECT * FROM `mytable` WHERE `id` = ?', [ 1 ]);

License

Licensed under the MIT License

Authors

Copyright(c) 2017 Fred Chien(錢逢祥) <cfsghost@gmail.com>

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago