build: 更新项目结构和配置
- 移除 .gitignore 中的多个文件和目录 - 删除 README.md 文件 - 移除 app.vue 文件 - 删除 nuxt.config.ts 文件
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import mysql from 'mysql';
|
||||
import { dbConfig } from '../config/db.config';
|
||||
import { cdkDbConfig } from '../config/db.config';
|
||||
|
||||
// 创建连接池
|
||||
const pool = mysql.createPool(dbConfig);
|
||||
const pool = mysql.createPool(cdkDbConfig);
|
||||
|
||||
// 获取数据库连接
|
||||
export const getConnection = (): Promise<mysql.PoolConnection> => {
|
||||
@@ -18,8 +18,10 @@ export const getConnection = (): Promise<mysql.PoolConnection> => {
|
||||
};
|
||||
|
||||
// 执行查询
|
||||
export const query = async (sql: string, values?: any[]): Promise<any> => {
|
||||
const connection = await getConnection();
|
||||
export const query = async (sql: string, values?: any[], connection?: mysql.PoolConnection): Promise<any> => {
|
||||
if (!connection) {
|
||||
connection = await getConnection()
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
connection.query(sql, values, (err, results) => {
|
||||
connection.release(); // 释放连接
|
||||
|
||||
Reference in New Issue
Block a user