Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ynnjs/ynn-plugin-mysql
https://github.com/ynnjs/ynn-plugin-mysql
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/ynnjs/ynn-plugin-mysql
- Owner: ynnjs
- Created: 2018-08-31T04:22:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T15:54:09.000Z (about 2 years ago)
- Last Synced: 2023-03-02T13:06:12.867Z (almost 2 years ago)
- Language: JavaScript
- Size: 1.16 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ynn-plugin-mysql
Ynn的MySQL连接管理插件
## Installation
```sh
$ npm install --save https://github.com/ynnjs/ynn-plugin-mysql.git
```## Usage
```js
const Ynn = require( 'ynn' );
const app = new Ynn( {
root : __dirname,
debugging : Ynn.DEBUGGING_DANGER,
logging : false,
plugins : {
// app.db
db : {
path : 'ynn-plugin-mysql',
options : {
config : {
host : 'localhost',
user : 'root',
port : 3306,
password : '',
supportBigNumbers : true,
bigNumberStrings : true
}
}
},
// 创建另外一个mysql链接,使用 app.anotherDB 获取
anotherDB : {
path : 'ynn-plugin-mysql',
options : {
// ...
}
}
}
} );
```### 注意事项
`plugin-mysql` 插件在每次请求中被调用时创建MySQL链接,请求结束后关闭对应链接。如果需要创建一个逻辑独立的链接,可使用 `app.db.connection.promise()`。 __详细配置项请参考[mysql2](https://github.com/sidorares/node-mysql2#readme)文档__