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) => {
3535 try {
3636 if ( ! pool ) {
3737 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+ }
3942 await pool . end ( )
40- return { data : rows , error : null }
43+ return { data : res . rows , error : null }
4144 }
4245
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 }
4551 } catch ( e : any ) {
4652 return { data : null , error : { message : e . message } }
4753 }
You can’t perform that action at this time.
0 commit comments