@aird/mysql
v3.0.3
Published
Node.js MySQL封装优化
Downloads
5
Readme
Dwing MySQL
安装
yarn add @dwing/mysql
ES7 使用
POOL
const {pool} = require('@dwing/mysql');
(async(){
// 传入配置,新建一个Pool,如果已有Pool则直接拿来使用
const cn = await pool({
host: '127.0.0.1',
user: 'root',
password: 'root',
database: 'test'
}); // 根据当前数据库配置创建一个连接
console.log(await cn.query('SELECT 1'));
})();
CONNECTION
const {connection} = require('@dwing/mysql');
(async(){
// 传入配置,新建一个连接,,如果已有连接则直接拿来使用
const cn = await connection({
host: '127.0.0.1',
user: 'root',
password: 'root',
database: 'test'
});
console.log(await cn.query('SELECT 1'));
})();
FORMAT
const {pool, format} = require('@dwing/mysql');
(async(){
const cn = await pool({
host: '127.0.0.1',
user: 'root',
password: 'root',
database: 'test'
});
console.log(await cn.query(format('SELECT 1')));
})();
License
MIT