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

Method read

packages/pg-cursor/index.js:234–257  ·  view source on GitHub ↗
(rows, cb)

Source from the content-addressed store, hash-verified

232 }
233
234 read(rows, cb) {
235 let promise
236
237 if (!cb) {
238 promise = new this._Promise((resolve, reject) => {
239 cb = (err, rows) => (err ? reject(err) : resolve(rows))
240 })
241 }
242
243 if (this.state === 'idle' || this.state === 'submitted') {
244 this._getRows(rows, cb)
245 } else if (this.state === 'busy' || this.state === 'initialized') {
246 this._queue.push([rows, cb])
247 } else if (this.state === 'error') {
248 setImmediate(() => cb(this._error))
249 } else if (this.state === 'done') {
250 setImmediate(() => cb(null, []))
251 } else {
252 throw new Error('Unknown state: ' + this.state)
253 }
254
255 // Return the promise (or undefined)
256 return promise
257 }
258}
259
260Cursor.prototype.end = util.deprecate(

Callers 15

runFunction · 0.95
submittable.jsFile · 0.80
copy-to.jsFile · 0.80
async-workflow.jsFile · 0.80
poolQueryPromiseFunction · 0.80
close.jsFile · 0.80
transactions.jsFile · 0.80
query-config.jsFile · 0.80
index.jsFile · 0.80
readFunction · 0.80
error-handling.jsFile · 0.80

Calls 2

_getRowsMethod · 0.95
cbFunction · 0.85

Tested by

no test coverage detected