Skip to content

Instantly share code, notes, and snippets.

@timwis
Last active August 11, 2016 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save timwis/e7185c2935d49d84bd32257bc990b14b to your computer and use it in GitHub Desktop.
Save timwis/e7185c2935d49d84bd32257bc990b14b to your computer and use it in GitHub Desktop.
client.select('*').from(opts.table).stream()
.pipe(through.obj(chunkToFiles))
.pipe(vfs.dest('./' + opts.table))
function chunkToFiles (chunk, enc, callback) {
const primaryKey = chunk[opts.primaryKey]
const keys = Object.keys(chunk)
keys.forEach((key) => {
const file = new File({
path: `./${primaryKey}/${key}`,
contents: new Buffer(chunk[key] + '')
})
this.push(file)
})
callback()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment