wvanbergen/node-vertica — pull request #39 by themadcreator (2014-09-26 21:16:18+00:00)
Title: Pass through callbacks in CopyInResponse method

This enabled users to receive notification when a COPY query has consumed the
current data. This can be used to stream bulk data efficiently using a COPY
query.

Example:

# `buffered` is a stream-like object that can emit 'data', 'done', and 'error' events and can be resumed when more data is needed.
copyIn = (transfer, success, fail) ->
buffered.on 'data', (data) -> transfer(data, -> buffered.resume())
buffered.on 'done', () -> success()
buffered.on 'error', (err) -> fail(err)
buffered.resume()

# Now we can stream in pipe-separated values into the DB
db.copy("COPY #{schema.table} (#{schema.columns.join(',')}) FROM STDIN DELIMITER '|' NULL '' ABORT ON ERROR", copyIn)

NOTES:

I regenerated the src using coffeescript 1.7.1, but some of the javascripts
resources appeared to update even though I did not modify the coffee source.