File tree Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -6,22 +6,29 @@ const SqlWe = (() => (class Sql extends WError {}))();
66
77const  predefinedSql  =  require ( './sqls/index.js' ) ( ) ; 
88
9- const  conn  =  ( ( )  =>  { 
10-     let  connection ; 
9+ const  connectionPool  =  ( log )  =>  { 
10+     let  pool ; 
1111    return  async ( config )  =>  { 
12-         if  ( connection  ===  undefined )  { 
13-             connection  =  new  Pool ( config ) ; 
14-             return  connection ; 
12+         if  ( pool  ===  undefined )  { 
13+             pool  =  new  Pool ( config ) ; 
14+             pool . on ( 'error' ,  ( e )  =>  log ( 'error' ,  'expose.sql.methods' ,  e ) ) ; 
15+             return  pool ; 
1516        } 
16-         return  connection ; 
17+         return  pool ; 
1718    } ; 
18- } ) ( ) ; 
19+ } ; 
1920
2021
21- module . exports  =  async ( config )  =>  { 
22+ module . exports  =  async ( 
23+     config , 
24+     { log =  ( )  =>  { } } 
25+ )  =>  { 
2226    const  { link : { gluePrefix =  '.' ,  schemas : sc }  =  { } }  =  config ; 
2327    const  schemas  =  sc  instanceof  Array  ? sc  : [ sc ] ; 
24-     const  link  =  await  conn ( config . connection ) ; 
28+     const  link  =  await  connectionPool ( log ) ( 
29+         config . connection , 
30+         { log} 
31+     ) ; 
2532    const  txMap  =  new  Map ( ) ; 
2633    let  txId  =  0 ; 
2734
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments