egg-real-mysql
v1.0.1
Published
based on node mysql and promise-mysql
Downloads
1
Readme
egg-real-mysql
Description
this plugin based on promise-mysql package, and promise-mysql based on node-mysql, so you can simply use it
the version on EggJs
egg-real-mysql version | egg 2.x --- | --- 2.x | 😁 1.x | ❓ 0.x | ❌
Install
$ npm i egg-real-mysql --save
Usage
// {app_root}/config/plugin.js
exports.realMysql = {
enable: true,
package: 'egg-real-mysql',
};
Configuration
// {app_root}/config/config.default.js
exports.mysql = {
client: {
host: '127.0.0.1',
port: '3306',
user: 'root',
password: 'root',
database: 'example',
},
app: true,
agent: false,
};
see config/config.default.js for more detail.
use on service
module.exports = app => {
return class extends app.Service {
async create(name) {
let data = {
id: '',
name: name
};
const result = await this.app.mysql.query('insert into list set ?', [ data ]).then(rows => {
return JSON.parse(JSON.stringify(rows));
});
return result;
}
};
};
Questions & Suggestions
Please open an issue