Ai config

This commit is contained in:
董海洋
2026-05-26 13:37:55 +08:00
parent 55452a2d21
commit 0c7ed3498d
42 changed files with 1264 additions and 767 deletions
+16
View File
@@ -62,9 +62,25 @@ async function initDatabase() {
}
}
async function transaction(callback) {
const connection = await pool.getConnection()
try {
await connection.beginTransaction()
const result = await callback(connection)
await connection.commit()
return result
} catch (error) {
await connection.rollback()
throw error
} finally {
connection.release()
}
}
module.exports = {
pool,
query,
transaction,
initDatabase,
config
}