Emit 'row' events on streams for progress tracking

This commit is contained in:
Brian M. Carlson
2013-10-28 21:27:15 -05:00
parent d3d648a623
commit c9c843fd07
4 changed files with 14 additions and 5 deletions
+1 -3
View File
@@ -10,13 +10,11 @@ var CopyStreamQuery = function(text) {
this.text = text
this._listeners = null
this._copyOutResponse = null
this.rowsRead = 0
}
util.inherits(CopyStreamQuery, Transform)
CopyStreamQuery.prototype.submit = function(connection) {
console.log('submitting')
connection.query(this.text)
this.connection = connection
this._listeners = connection.stream.listeners('data')
@@ -79,8 +77,8 @@ CopyStreamQuery.prototype._transform = function(chunk, enc, cb) {
offset += 5
var slice = chunk.slice(offset, offset + length)
offset += length
this.rowsRead++
this.push(slice)
this.emit('row')
} else {
break;
}