1 |
|
2 | /**
|
3 | * Copyright (c) 2010-2017 Brian Carlson (brian.m.carlson@gmail.com)
|
4 | * All rights reserved.
|
5 | *
|
6 | * This source code is licensed under the MIT license found in the
|
7 | * README.md file in the root directory of this source tree.
|
8 | */
|
9 |
|
10 | module.exports = {
|
11 | // database host. defaults to localhost
|
12 | host: 'localhost',
|
13 |
|
14 | // database user's name
|
15 | user: process.platform === 'win32' ? process.env.USERNAME : process.env.USER,
|
16 |
|
17 | // name of database to connect
|
18 | database: undefined,
|
19 |
|
20 | // database user's password
|
21 | password: null,
|
22 |
|
23 | // a Postgres connection string to be used instead of setting individual connection items
|
24 | // NOTE: Setting this value will cause it to override any other value (such as database or user) defined
|
25 | // in the defaults object.
|
26 | connectionString: undefined,
|
27 |
|
28 | // database port
|
29 | port: 5432,
|
30 |
|
31 | // number of rows to return at a time from a prepared statement's
|
32 | // portal. 0 will return all rows at once
|
33 | rows: 0,
|
34 |
|
35 | // binary result mode
|
36 | binary: false,
|
37 |
|
38 | // Connection pool options - see https://github.com/brianc/node-pg-pool
|
39 |
|
40 | // number of connections to use in connection pool
|
41 | // 0 will disable connection pooling
|
42 | max: 10,
|
43 |
|
44 | // max milliseconds a client can go unused before it is removed
|
45 | // from the pool and destroyed
|
46 | idleTimeoutMillis: 30000,
|
47 |
|
48 | client_encoding: '',
|
49 |
|
50 | ssl: false,
|
51 |
|
52 | application_name: undefined,
|
53 |
|
54 | fallback_application_name: undefined,
|
55 |
|
56 | parseInputDatesAsUTC: false,
|
57 |
|
58 | // max milliseconds any query using this connection will execute for before timing out in error.
|
59 | // false=unlimited
|
60 | statement_timeout: false,
|
61 |
|
62 | // Terminate any session with an open transaction that has been idle for longer than the specified duration in milliseconds
|
63 | // false=unlimited
|
64 | idle_in_transaction_session_timeout: false,
|
65 |
|
66 | // max milliseconds to wait for query to complete (client side)
|
67 | query_timeout: false,
|
68 |
|
69 | connect_timeout: 0,
|
70 |
|
71 | keepalives: 1,
|
72 |
|
73 | keepalives_idle: 0,
|
74 | }
|
75 |
|
76 | var pgTypes = require('pg-types')
|
77 | // save default parsers
|
78 | var parseBigInteger = pgTypes.getTypeParser(20, 'text')
|
79 | var parseBigIntegerArray = pgTypes.getTypeParser(1016, 'text')
|
80 |
|
81 | // parse int8 so you can get your count values as actual numbers
|
82 | module.exports.__defineSetter__('parseInt8', function (val) {
|
83 | pgTypes.setTypeParser(20, 'text', val ? pgTypes.getTypeParser(23, 'text') : parseBigInteger)
|
84 | pgTypes.setTypeParser(1016, 'text', val ? pgTypes.getTypeParser(1007, 'text') : parseBigIntegerArray)
|
85 | })
|