File tree 2 files changed +7
-9
lines changed
2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -18,18 +18,16 @@ class Database {
18
18
}
19
19
20
20
async query ( sql , args ) {
21
- const connection = await this . getConnection ( ) ;
22
- let isDestroyed = false ;
23
21
try {
24
- const result = await connection . query ( sql , args ) ;
22
+ const connection = await this . getConnection ( ) ;
23
+ let result ;
24
+ await this . withNewTransaction ( connection , async ( ) => {
25
+ result = await connection . query ( sql , args ) ;
26
+ } ) ;
25
27
return result [ 0 ] ;
26
28
} catch ( error ) {
27
29
console . log ( "SQL ERROR SQL ERROR SQL ERROR SQL ERROR SQL ERROR\n" + error ) ;
28
- if ( error . toString ( ) . includes ( "closed state" ) ) isDestroyed = true ;
29
30
throw error ;
30
- } finally {
31
- if ( isDestroyed ) connection . destroy ( ) ;
32
- else connection . release ( ) ;
33
31
}
34
32
}
35
33
@@ -81,7 +79,7 @@ class Database {
81
79
} ) ;
82
80
} catch ( err ) {
83
81
console . log ( "Failed to import users. Error: " + err ) ;
84
- }
82
+ }
85
83
}
86
84
}
87
85
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " g5api" ,
3
- "version" : " 1.2.0" ,
3
+ "version" : " 1.2.0.1 " ,
4
4
"private" : true ,
5
5
"licenses" : [
6
6
{
You can’t perform that action at this time.
0 commit comments