Skip to content

Instantly share code, notes, and snippets.

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