Permalink
Comparing changes
Open a pull request
- 3 commits
- 5 files changed
- 0 commit comments
- 1 contributor
Unified
Split
Showing
with
13 additions
and 14 deletions.
- +7 −1 bin/import.js
- +3 −6 lib/export.js
- +1 −3 lib/import.js
- +1 −3 lib/util/progress.js
- +1 −1 usage/write.txt
| @@ -63,7 +63,13 @@ function handleImport (args) { | ||
| version: db.head | ||
| } | ||
| console.log(JSON.stringify(output)) | ||
| } else console.error('Done importing data. \nVersion: ' + db.head) | ||
| } else { | ||
| if (importer.progress.puts === 0 && importer.progress.deletes === 0) { | ||
| console.error('No changes were made.') | ||
| } else { | ||
| console.error('Done importing data. \nVersion: ' + db.head) | ||
| } | ||
| } | ||
| }) | ||
| } | ||
| } | ||
| @@ -6,12 +6,9 @@ var debug = require('debug')('src/export') | ||
| module.exports = function createExportStream (db, opts) { | ||
| var parseOutput = through.obj(function (data, enc, next) { | ||
| debug('exporting through data', data) | ||
| if (data.content === 'row') { | ||
| var row = data.value | ||
| row.key = data.key | ||
| return next(null, row) | ||
| } | ||
| next() | ||
| if (data.content === 'file' && !opts.files) return next() | ||
| if (opts.full) return next(null, data) | ||
| next(null, data.value) | ||
| }) | ||
| return pumpify(db.createReadStream(opts), parseOutput, formatData(opts.format)) | ||
| @@ -10,8 +10,6 @@ module.exports = function (db, opts) { | ||
| var transform = through.obj(function (obj, enc, next) { | ||
| debug('heres my obj!', obj) | ||
| stream.progress.keys++ | ||
| stream.emit('progress') | ||
| var key = obj[opts.key] || obj.key || uuid() | ||
| var doc = {type: 'put', key: key, value: obj} | ||
| next(null, doc) | ||
| @@ -24,6 +22,6 @@ module.exports = function (db, opts) { | ||
| }) | ||
| var stream = pumpify(parseInputStream(opts), transform, writeStream) | ||
| stream.progress = {keys: 0} | ||
| stream.progress = writeStream.progress | ||
| return stream | ||
| } | ||
| @@ -10,15 +10,13 @@ module.exports = function (stream, options) { | ||
| function printProgress () { | ||
| if (options.bytes) { | ||
| log(options.verb + ' (' + prettyBytes(stream.progress.bytes) + ').\n') | ||
| } else if (options.replicate) { | ||
| } else { | ||
| log( | ||
| options.verb + | ||
| ' [+' + stream.progress.puts + ', -' + stream.progress.deletes + ']' + | ||
| (stream.progress.files ? ' and ' + stream.progress.files + ' file(s)' : '') + | ||
| '.\n' | ||
| ) | ||
| } else { | ||
| log(options.verb + ' ' + stream.progress.keys + ' ' + options.subject + '.\n') | ||
| } | ||
| } | ||
| } | ||
| @@ -4,7 +4,7 @@ Write a file to dat: | ||
| dat write <path-to-file> | ||
| -d <dataset-name> # the name of the dataset to create. required | ||
| -n <filename> # the name of the file. if not supplied, uses the path | ||
| -k <filename> # the key to store the file. if not supplied, uses the filename | ||
| Stream data from stdin: | ||