-
-
Save blissdev/25784b641d6ca41d4f7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Cursor = require('pg-cursor') | |
var pg = require('pg') | |
var pgLocation = 'postgres://postgres@localhost:49153/postgres' | |
var client = new pg.Client(pgLocation) | |
client.connect(function(err) { | |
if(err) return console.error('could not connect to pg', err) | |
var cursor = client.query(new Cursor('select email, password from account', [])) | |
var read = function() { | |
console.log(cursor) | |
cursor.read(100, function(err, rows) { | |
if(err) return done(err) | |
if(!rows.length) { | |
// we are done here | |
console.log('done') | |
done() | |
} | |
console.log('got rows of length', rows.length) | |
setImmediate(read) | |
}) | |
} | |
read() | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cursor_usage.js:14 | |
cursor.read(100, function(err, rows) { | |
^ | |
TypeError: Object [object Object] has no method 'read' | |
at read (cursor_usage.js:14:12) | |
at cursor_usage.js:29:3 | |
at null.<anonymous> (node_modules/pg/lib/client.js:134:7) | |
at g (events.js:175:14) | |
at EventEmitter.emit (events.js:117:20) | |
at null.<anonymous> (node_modules/pg/lib/connection.js:97:12) | |
at Socket.EventEmitter.emit (events.js:95:17) | |
at Socket.<anonymous> (_stream_readable.js:746:14) | |
at Socket.EventEmitter.emit (events.js:92:17) | |
at emitReadable_ (_stream_readable.js:408:10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment