@@ -45,34 +45,34 @@ You can use either a `postgres://` url connection string or the options to defin
45
45
46
46
``` js
47
47
const sql = postgres (' postgres://username:password@host:port/database' , {
48
- host : ' ' , // Postgres ip address[s] or domain name[s]
49
- port : 5432 , // Postgres server port[s]
50
- path : ' ' , // unix socket path (usually '/tmp')
51
- database : ' ' , // Name of database to connect to
52
- username : ' ' , // Username of database user
53
- password : ' ' , // Password of database user
54
- ssl : false , // true, prefer, require, tls.connect options
55
- max : 10 , // Max number of connections
56
- idle_timeout : 0 , // Idle connection timeout in seconds
57
- connect_timeout : 30 , // Connect timeout in seconds
58
- no_prepare : false , // No automatic creation of prepared statements
59
- types : [], // Array of custom types, see more below
60
- onnotice : fn, // Defaults to console.log
61
- onparameter : fn, // (key, value) when server param change
62
- debug : fn, // Is called with (connection, query, params)
48
+ host : ' ' , // Postgres ip address[s] or domain name[s]
49
+ port : 5432 , // Postgres server port[s]
50
+ path : ' ' , // unix socket path (usually '/tmp')
51
+ database : ' ' , // Name of database to connect to
52
+ username : ' ' , // Username of database user
53
+ password : ' ' , // Password of database user
54
+ ssl : false , // true, prefer, require, tls.connect options
55
+ max : 10 , // Max number of connections
56
+ idle_timeout : 0 , // Idle connection timeout in seconds
57
+ connect_timeout : 30 , // Connect timeout in seconds
58
+ no_prepare : false , // No automatic creation of prepared statements
59
+ types : [], // Array of custom types, see more below
60
+ onnotice : fn, // Defaults to console.log
61
+ onparameter : fn, // (key, value) when server param change
62
+ debug : fn, // Is called with (connection, query, params)
63
63
transform : {
64
- column : fn, // Transforms incoming column names
65
- value : fn, // Transforms incoming row values
66
- row : fn // Transforms entire rows
64
+ column : {to ?: fn, from ?: fn}, // Transforms incoming or outgoing column names
65
+ value : {to ?: fn, from ?: fn}, // Transforms incoming or outgoing row values
66
+ row : {to ?: fn, from ?: fn}, // Transforms entire incoming or outgoing rows
67
67
},
68
68
connection : {
69
- application_name : ' postgres.js' , // Default application_name
70
- ... // Other connection parameters
69
+ application_name : ' postgres.js' , // Default application_name
70
+ ... // Other connection parameters
71
71
},
72
- target_session_attrs : null , // Use 'read-write' with multiple hosts to
73
- // ensure only connecting to primary
74
- fetch_array_types : true , // Disable automatically fetching array types
75
- // on initial connection.
72
+ target_session_attrs : null , // Use 'read-write' with multiple hosts to
73
+ // ensure only connecting to primary
74
+ fetch_array_types : true , // Disable automatically fetching array types
75
+ // on initial connection.
76
76
})
77
77
```
78
78
0 commit comments