MCPcopy
hub / github.com/brianc/node-postgres / Client

Class Client

packages/pg/lib/client.js:50–767  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50class Client extends EventEmitter {
51 constructor(config) {
52 super()
53
54 this.connectionParameters = new ConnectionParameters(config)
55 this.user = this.connectionParameters.user
56 this.database = this.connectionParameters.database
57 this.port = this.connectionParameters.port
58 this.host = this.connectionParameters.host
59
60 // "hiding" the password so it doesn't show up in stack traces
61 // or if the client is console.logged
62 Object.defineProperty(this, 'password', {
63 configurable: true,
64 enumerable: false,
65 writable: true,
66 value: this.connectionParameters.password,
67 })
68
69 this.replication = this.connectionParameters.replication
70
71 const c = config || {}
72
73 if (c.Promise) {
74 byoPromiseDeprecationNotice()
75 }
76 this._Promise = c.Promise || global.Promise
77 this._types = new TypeOverrides(c.types)
78 this._ending = false
79 this._ended = false
80 this._connecting = false
81 this._connected = false
82 this._connectionError = false
83 this._queryable = true
84 this._activeQuery = null
85 this._txStatus = null
86
87 this.enableChannelBinding = Boolean(c.enableChannelBinding) // set true to use SCRAM-SHA-256-PLUS when offered
88 this.scramMaxIterations = coerceNumberOrDefault(c.scramMaxIterations, sasl.DEFAULT_MAX_SCRAM_ITERATIONS)
89 this.connection =
90 c.connection ||
91 new Connection({
92 stream: c.stream,
93 ssl: this.connectionParameters.ssl,
94 sslNegotiation: this.connectionParameters.sslnegotiation,
95 keepAlive: c.keepAlive || false,
96 keepAliveInitialDelayMillis: c.keepAliveInitialDelayMillis || 0,
97 encoding: this.connectionParameters.client_encoding || 'utf8',
98 })
99 this._queryQueue = []
100 this.binary = c.binary || defaults.binary
101 this.processID = null
102 this.secretKey = null
103 this.ssl = this.connectionParameters.ssl || false
104 this.sslNegotiation = this.connectionParameters.sslnegotiation || 'postgres'
105 // As with Password, make SSL->Key (the private key) non-enumerable.
106 // It won't show up in stack traces
107 // or if the client is console.logged

Callers 6

copy-to.jsFile · 0.85
huge-query.jsFile · 0.85
copy-from.jsFile · 0.85
index.jsFile · 0.85
query-sync.jsFile · 0.85
query-async.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected