File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -35,13 +35,19 @@ export const init: (config: PoolConfig) => {
35
35
try {
36
36
if ( ! pool ) {
37
37
const pool = new Pool ( config )
38
- const { rows } = await pool . query ( sql )
38
+ let res = await pool . query ( sql )
39
+ if ( Array . isArray ( res ) ) {
40
+ res = res . reverse ( ) . find ( ( x ) => x . rows . length !== 0 ) ?? { rows : [ ] }
41
+ }
39
42
await pool . end ( )
40
- return { data : rows , error : null }
43
+ return { data : res . rows , error : null }
41
44
}
42
45
43
- const { rows } = await pool . query ( sql )
44
- return { data : rows , error : null }
46
+ let res = await pool . query ( sql )
47
+ if ( Array . isArray ( res ) ) {
48
+ res = res . reverse ( ) . find ( ( x ) => x . rows . length !== 0 ) ?? { rows : [ ] }
49
+ }
50
+ return { data : res . rows , error : null }
45
51
} catch ( e : any ) {
46
52
return { data : null , error : { message : e . message } }
47
53
}
You can’t perform that action at this time.
0 commit comments