File tree 1 file changed +16
-9
lines changed
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 {}))();
6
6
7
7
const predefinedSql = require ( './sqls/index.js' ) ( ) ;
8
8
9
- const conn = ( ( ) => {
10
- let connection ;
9
+ const connectionPool = ( log ) => {
10
+ let pool ;
11
11
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 ;
15
16
}
16
- return connection ;
17
+ return pool ;
17
18
} ;
18
- } ) ( ) ;
19
+ } ;
19
20
20
21
21
- module . exports = async ( config ) => {
22
+ module . exports = async (
23
+ config ,
24
+ { log = ( ) => { } }
25
+ ) => {
22
26
const { link : { gluePrefix = '.' , schemas : sc } = { } } = config ;
23
27
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
+ ) ;
25
32
const txMap = new Map ( ) ;
26
33
let txId = 0 ;
27
34
You can’t perform that action at this time.
0 commit comments