defaults.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. 'use strict'
  2. module.exports = {
  3. // database host. defaults to localhost
  4. host: 'localhost',
  5. // database user's name
  6. user: process.platform === 'win32' ? process.env.USERNAME : process.env.USER,
  7. // name of database to connect
  8. database: undefined,
  9. // database user's password
  10. password: null,
  11. // a Postgres connection string to be used instead of setting individual connection items
  12. // NOTE: Setting this value will cause it to override any other value (such as database or user) defined
  13. // in the defaults object.
  14. connectionString: undefined,
  15. // database port
  16. port: 5432,
  17. // number of rows to return at a time from a prepared statement's
  18. // portal. 0 will return all rows at once
  19. rows: 0,
  20. // binary result mode
  21. binary: false,
  22. // Connection pool options - see https://github.com/brianc/node-pg-pool
  23. // number of connections to use in connection pool
  24. // 0 will disable connection pooling
  25. max: 10,
  26. // max milliseconds a client can go unused before it is removed
  27. // from the pool and destroyed
  28. idleTimeoutMillis: 30000,
  29. client_encoding: '',
  30. ssl: false,
  31. application_name: undefined,
  32. fallback_application_name: undefined,
  33. options: undefined,
  34. parseInputDatesAsUTC: false,
  35. // max milliseconds any query using this connection will execute for before timing out in error.
  36. // false=unlimited
  37. statement_timeout: false,
  38. // Terminate any session with an open transaction that has been idle for longer than the specified duration in milliseconds
  39. // false=unlimited
  40. idle_in_transaction_session_timeout: false,
  41. // max milliseconds to wait for query to complete (client side)
  42. query_timeout: false,
  43. connect_timeout: 0,
  44. keepalives: 1,
  45. keepalives_idle: 0,
  46. }
  47. var pgTypes = require('pg-types')
  48. // save default parsers
  49. var parseBigInteger = pgTypes.getTypeParser(20, 'text')
  50. var parseBigIntegerArray = pgTypes.getTypeParser(1016, 'text')
  51. // parse int8 so you can get your count values as actual numbers
  52. module.exports.__defineSetter__('parseInt8', function (val) {
  53. pgTypes.setTypeParser(20, 'text', val ? pgTypes.getTypeParser(23, 'text') : parseBigInteger)
  54. pgTypes.setTypeParser(1016, 'text', val ? pgTypes.getTypeParser(1007, 'text') : parseBigIntegerArray)
  55. })