添加说明文件
This commit is contained in:
@@ -1,7 +1,22 @@
|
||||
/**
|
||||
* @file MySQLConnection.ts
|
||||
* @version 1.0.0
|
||||
* @version 1.0.1
|
||||
* @description MySQL数据库连接池
|
||||
*
|
||||
* 该文件提供了MySQL数据库连接池的实现,包括以下功能:
|
||||
* - 创建数据库连接池
|
||||
* - 自动测试数据库连接
|
||||
* - 数据库基础错误处理
|
||||
*
|
||||
* ## 配置项说明
|
||||
* 在 `config.ts` 文件中,可以配置以下选项:
|
||||
* - `enable`: 是否启用 MySQL 数据库
|
||||
* - `host`: 数据库主机地址
|
||||
* - `port`: 数据库端口号
|
||||
* - `database`: 数据库名称
|
||||
* - `user`: 数据库用户名
|
||||
* - `password`: 数据库密码
|
||||
*
|
||||
*/
|
||||
import mysql from "mysql2/promise";
|
||||
import Logger from "@lib/Logger/Logger";
|
||||
@@ -12,7 +27,7 @@ class MySQLConnectPool {
|
||||
private logger = new Logger('MySQL');
|
||||
|
||||
constructor() {
|
||||
if(!config.mysql.enable){
|
||||
if (!config.mysql.enable) {
|
||||
this.logger.warn('Database is disabled, initialization terminated');
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user