2016-06-24 23:56:43 +08:00
|
|
|
/**
|
2017-05-18 05:47:07 +08:00
|
|
|
* Copyright (c) 2010-2017 Brian Carlson (brian.m.carlson@gmail.com)
|
2016-06-24 23:56:43 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* README.md file in the root directory of this source tree.
|
|
|
|
*/
|
|
|
|
|
2013-08-29 13:04:27 +08:00
|
|
|
var defaults = module.exports = {
|
2015-10-09 14:02:15 +08:00
|
|
|
// database host. defaults to localhost
|
2013-06-30 05:46:45 +08:00
|
|
|
host: 'localhost',
|
|
|
|
|
2010-11-21 04:09:18 +08:00
|
|
|
//database user's name
|
2013-11-21 03:19:31 +08:00
|
|
|
user: process.platform === 'win32' ? process.env.USERNAME : process.env.USER,
|
2012-02-03 13:27:52 +08:00
|
|
|
|
2010-11-21 04:09:18 +08:00
|
|
|
//name of database to connect
|
2013-11-21 03:19:31 +08:00
|
|
|
database: process.platform === 'win32' ? process.env.USERNAME : process.env.USER,
|
2012-02-03 13:27:52 +08:00
|
|
|
|
2010-11-21 04:09:18 +08:00
|
|
|
//database user's password
|
2011-03-02 04:13:04 +08:00
|
|
|
password: null,
|
2013-01-24 07:44:43 +08:00
|
|
|
|
2016-06-08 05:09:22 +08:00
|
|
|
// a Postgres connection string to be used instead of setting individual connection items
|
|
|
|
// NOTE: Setting this value will cause it to override any other value (such as database or user) defined
|
|
|
|
// in the defaults object.
|
|
|
|
connectionString : undefined,
|
|
|
|
|
2010-11-21 04:09:18 +08:00
|
|
|
//database port
|
|
|
|
port: 5432,
|
2012-02-03 13:27:52 +08:00
|
|
|
|
2010-11-21 04:09:18 +08:00
|
|
|
//number of rows to return at a time from a prepared statement's
|
|
|
|
//portal. 0 will return all rows at once
|
|
|
|
rows: 0,
|
2012-07-16 11:08:26 +08:00
|
|
|
|
|
|
|
// binary result mode
|
|
|
|
binary: false,
|
2013-01-24 07:44:43 +08:00
|
|
|
|
2012-07-16 11:08:26 +08:00
|
|
|
//Connection pool options - see https://github.com/coopernurse/node-pool
|
2010-11-21 04:09:18 +08:00
|
|
|
//number of connections to use in connection pool
|
|
|
|
//0 will disable connection pooling
|
2011-08-12 10:52:29 +08:00
|
|
|
poolSize: 10,
|
2012-02-03 13:27:52 +08:00
|
|
|
|
|
|
|
//max milliseconds a client can go unused before it is removed
|
|
|
|
//from the pool and destroyed
|
2011-11-21 18:45:55 +08:00
|
|
|
poolIdleTimeout: 30000,
|
2012-02-03 13:27:52 +08:00
|
|
|
|
2015-10-09 14:02:15 +08:00
|
|
|
//frequency to check for idle clients within the client pool
|
2012-02-03 13:27:52 +08:00
|
|
|
reapIntervalMillis: 1000,
|
|
|
|
|
2016-06-08 05:05:55 +08:00
|
|
|
//if true the most recently released resources will be the first to be allocated
|
|
|
|
returnToHead: false,
|
|
|
|
|
2012-07-16 11:08:26 +08:00
|
|
|
//pool log function / boolean
|
2013-06-07 03:06:52 +08:00
|
|
|
poolLog: false,
|
|
|
|
|
2013-09-06 05:51:16 +08:00
|
|
|
client_encoding: "",
|
|
|
|
|
2014-01-06 01:08:58 +08:00
|
|
|
ssl: false,
|
|
|
|
|
2016-02-24 09:02:08 +08:00
|
|
|
application_name: undefined,
|
|
|
|
fallback_application_name: undefined,
|
|
|
|
|
|
|
|
parseInputDatesAsUTC: false
|
2013-01-21 21:54:19 +08:00
|
|
|
};
|
2013-08-29 13:04:27 +08:00
|
|
|
|
2016-12-16 23:44:19 +08:00
|
|
|
var pgTypes = require('pg-types');
|
|
|
|
// save default parsers
|
|
|
|
var parseBigInteger = pgTypes.getTypeParser(20, 'text');
|
|
|
|
var parseBigIntegerArray = pgTypes.getTypeParser(1016, 'text');
|
|
|
|
|
2013-08-29 13:04:27 +08:00
|
|
|
//parse int8 so you can get your count values as actual numbers
|
|
|
|
module.exports.__defineSetter__("parseInt8", function(val) {
|
2016-12-16 23:44:19 +08:00
|
|
|
pgTypes.setTypeParser(20, 'text', val ? pgTypes.getTypeParser(23, 'text') : parseBigInteger);
|
|
|
|
pgTypes.setTypeParser(1016, 'text', val ? pgTypes.getTypeParser(1007, 'text') : parseBigIntegerArray);
|
2013-08-29 13:04:27 +08:00
|
|
|
});
|