@@ -5,14 +5,37 @@ var utils = require('../utils')
5
5
var pg = require ( 'pg' )
6
6
7
7
function createPostgresDb ( options = { } ) {
8
+ function parseConfig ( ) {
9
+ var config = { } ;
10
+
11
+ if ( options . connectionString != undefined ) {
12
+ config . connectionString = options . connectionString ;
13
+ } else {
14
+ config . user = options . user ;
15
+ config . host = options . host || 'localhost' ;
16
+ config . database = options . database ;
17
+ config . password = options . password ;
18
+ config . port = options . port || 5432 ;
19
+ }
20
+
21
+ if ( options . ssl != undefined ) {
22
+ config . ssl = options . ssl ;
23
+ }
24
+
25
+ if ( options . types != undefined ) {
26
+ config . types = options . types ;
27
+ }
28
+
29
+ if ( options . statement_timeout != undefined ) {
30
+ config . statement_timeout = options . statement_timeout ;
31
+ }
32
+
33
+ return config ;
34
+ } ;
35
+
36
+
8
37
return function ( pdfBotConfiguration ) {
9
- var db = new pg . Client ( {
10
- user : options . user ,
11
- host : options . host || 'localhost' ,
12
- database : options . database ,
13
- password : options . password ,
14
- port : options . port || 5432 ,
15
- } )
38
+ var db = new pg . Client ( parseConfig ( ) ) ;
16
39
db . connect ( )
17
40
18
41
var createDbMethod = function ( func ) {
0 commit comments