defaults.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. // Abort any statement that waits longer than the specified duration in milliseconds while attempting to acquire a lock.
  39. // false=unlimited
  40. lock_timeout: false,
  41. // Terminate any session with an open transaction that has been idle for longer than the specified duration in milliseconds
  42. // false=unlimited
  43. idle_in_transaction_session_timeout: false,
  44. // max milliseconds to wait for query to complete (client side)
  45. query_timeout: false,
  46. connect_timeout: 0,
  47. keepalives: 1,
  48. keepalives_idle: 0,
  49. }
  50. var pgTypes = require('pg-types')
  51. // save default parsers
  52. var parseBigInteger = pgTypes.getTypeParser(20, 'text')
  53. var parseBigIntegerArray = pgTypes.getTypeParser(1016, 'text')
  54. // parse int8 so you can get your count values as actual numbers
  55. module.exports.__defineSetter__('parseInt8', function (val) {
  56. pgTypes.setTypeParser(20, 'text', val ? pgTypes.getTypeParser(23, 'text') : parseBigInteger)
  57. pgTypes.setTypeParser(1016, 'text', val ? pgTypes.getTypeParser(1007, 'text') : parseBigIntegerArray)
  58. })