@@ -23,7 +23,10 @@ export class MySQLConnection implements DatabaseConnection {
2323 } ) ;
2424 }
2525
26- async executeQuery < T > ( query : string , params : any [ ] = [ ] ) {
26+ async executeQuery < T > (
27+ query : string ,
28+ params : any [ ] = [ ] ,
29+ ) : Promise < T [ ] | null > {
2730 let connection : PoolConnection ;
2831 try {
2932 connection = await this . pool . getConnection ( ) ;
@@ -33,7 +36,7 @@ export class MySQLConnection implements DatabaseConnection {
3336 logger . error (
3437 `${ this . nameTag } 쿼리 ${ query } μ€ν μ€ μ€λ₯ λ°μ
3538 μ€λ₯ λ©μμ§: ${ error . message }
36- μ€ν νΈλ μ΄μ€: ${ error . stack } `
39+ μ€ν νΈλ μ΄μ€: ${ error . stack } ` ,
3740 ) ;
3841 } finally {
3942 if ( connection ) {
@@ -43,13 +46,42 @@ export class MySQLConnection implements DatabaseConnection {
4346 logger . error (
4447 `${ this . nameTag } connection release μ€ μ€λ₯ λ°μ
4548 μ€λ₯ λ©μμ§: ${ error . message }
46- μ€ν νΈλ μ΄μ€: ${ error . stack } `
49+ μ€ν νΈλ μ΄μ€: ${ error . stack } ` ,
4750 ) ;
4851 }
4952 }
5053 }
5154 }
5255
56+ async executeQueryStrict < T > ( query : string , params : any [ ] = [ ] ) : Promise < T [ ] > {
57+ let connection : PoolConnection ;
58+ try {
59+ connection = await this . pool . getConnection ( ) ;
60+ const [ rows ] = await connection . query ( query , params ) ;
61+ return rows as T [ ] ;
62+ } catch ( error ) {
63+ logger . error (
64+ `${ this . nameTag } 쿼리 ${ query } μ€ν μ€ μ€λ₯ λ°μ
65+ μ€λ₯ λ©μμ§: ${ error . message }
66+ μ€ν νΈλ μ΄μ€: ${ error . stack } ` ,
67+ ) ;
68+ throw error ;
69+ } finally {
70+ if ( connection ) {
71+ try {
72+ if ( connection ) connection . release ( ) ;
73+ } catch ( error ) {
74+ logger . error (
75+ `${ this . nameTag } connection release μ€ μ€λ₯ λ°μ
76+ μ€λ₯ λ©μμ§: ${ error . message }
77+ μ€ν νΈλ μ΄μ€: ${ error . stack } ` ,
78+ ) ;
79+ throw error ;
80+ }
81+ }
82+ }
83+ }
84+
5385 public async end ( ) {
5486 await this . pool . end ( ) ;
5587 }
0 commit comments