Created
January 28, 2015 17:24
-
-
Save brianc/d463f5d10ba3cad14320 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 lineStream; <-- assume this is a readable stream of lines of text utf8 encoded | |
var through2 = require('through2') | |
var terminatingStream = through2(function(line, enc, cb) { | |
query('INSERT INTO line_table line VALUE ($)', [line], function(err, res) { | |
if (err) return cb(err); | |
return cb(null, line); | |
}); | |
}); | |
//pipe the output of terminatingStream to standard out | |
//so the data will start 'flowing' through the pipe | |
lineStream.pipe(terminatingStream).pipe(process.stdout); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment