0.0.1 • Published 4 years ago

@busyhe/ynn-plugin-mysql v0.0.1

Weekly downloads
-
License
-
Repository
github
Last release
4 years ago

@busyhe/ynn-plugin-mysql

Ynn的MySQL连接管理插件

Installation

$ npm install --save @busyhe/ynn-plugin-mysql

Usage

const Ynn = require( 'ynn' );
const app = new Ynn( {
    root : __dirname,
    debugging : Ynn.DEBUGGING_DANGER,
    logging : false,
    plugins : {
        // app.db
        db : {
            path : '@busyhe/ynn-plugin-mysql',
            options : {
                config : {
                    host : 'localhost',
                    user : 'root',
                    port : 3306,
                    password : '',
                    supportBigNumbers : true,
                    bigNumberStrings : true
                }
            }
        },
        // 创建另外一个mysql链接,使用 app.anotherDB 获取
        anotherDB : {
            path : '@busyhe/ynn-plugin-mysql',
            options : {
                // ...
            }
        }
    }
} );

注意事项

@busyhe/ynn-plugin-mysql 插件在每次请求中被调用时创建MySQL链接,请求结束后关闭对应链接。如果需要创建一个逻辑独立的链接,可使用 app.db.connection.promise()详细配置项请参考mysql2文档