Ai config
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user