Skip to content

Commit

Permalink
Merge pull request #7 from firebase/readme_edits
Browse files Browse the repository at this point in the history
updated firebase database wording
  • Loading branch information
sararob committed May 26, 2015
2 parents a257b7d + c776f5d commit c4a4214
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Firebase-Import
Firebase-import is a helper utility for importing large JSON files into [Firebase](https://www.firebase.com/). It
Firebase-import is a helper utility for importing large JSON files into your [Firebase](https://www.firebase.com/) database. It
breaks the JSON into smaller chunks and uploads them individually through the Firebase API.

To import files bigger than 250MB, use [Firebase Streaming Import](https://github.com/firebase/firebase-streaming-import).
Expand All @@ -21,7 +21,7 @@ or install it locally and add it to your path:
Usage: firebase-import

Options:
--firebase_url, -f Firebase URL (e.g. https://test.firebaseio.com/dest/path). [required]
--firebase_url, -f Firebase database URL (e.g. https://test.firebaseio.com/dest/path). [required]
--json, -j The JSON file to import. [required]
--merge, -m Write the top-level children without overwriting the whole parent. [boolean]
--force Don't prompt before overwriting data. [boolean]
Expand Down
26 changes: 13 additions & 13 deletions bin/firebase-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ var Firebase = require('firebase'),
var CHUNK_SIZE = 1024*1024;

// Keep ~50 writes outstanding at a time (this increases throughput, so we're not delayed by server round-trips).
var OUTSTANDING_WRITE_COUNT = 50;
var OUTSTANDING_WRITE_COUNT = 50;

var argv = require('optimist')
.usage('Usage: $0')

.demand('firebase_url')
.describe('firebase_url', 'Firebase URL (e.g. https://test.firebaseio.com/dest/path).')
.describe('firebase_url', 'Firebase database URL (e.g. https://test.firebaseio.com/dest/path).')
.alias('f', 'firebase_url')

.demand('json')
.describe('json', 'The JSON file to import.')
.alias('j', 'json')

.boolean('merge')
.describe('merge', 'Write the top-level children without overwriting the whole parent.')
.alias('m', 'merge')

.boolean('force')
.describe('force', 'Don\'t prompt before overwriting data.')

.describe('auth', 'Specify an auth token to use (e.g. your Firebase Secret).')
.describe('auth', 'Specify an auth token to use (or your Firebase Secret).')
.alias('a', 'auth')

.argv;
Expand Down Expand Up @@ -94,7 +94,7 @@ function start(ref) {
// Need to split into chunks at the top level to ensure we don't overwrite the parent.
splitTopLevel = true;
}

console.log('Preparing JSON for import... (may take a minute)');
var chunks = createChunks(ref, json, splitTopLevel);

Expand Down Expand Up @@ -138,7 +138,7 @@ function chunkInternal(ref, json, forceSplit) {
priority = json['.priority'];
size += json['.priority'].toString().length;
}

var value = json;
if (jsonIsObject && ('.value' in json)) {
size += 9; // ".value":
Expand Down Expand Up @@ -188,13 +188,13 @@ function chunkInternal(ref, json, forceSplit) {
function ChunkUploader(chunks) {
this.next = 0;
this.chunks = chunks;
this.bar = new ProgressBar('Importing [:bar] :percent (:current/:total)',
this.bar = new ProgressBar('Importing [:bar] :percent (:current/:total)',
{ width: 50, total: chunks.length, incomplete: ' ' });
}

ChunkUploader.prototype.go = function(onComplete) {
this.onComplete = onComplete;

for(var i = 0; i < OUTSTANDING_WRITE_COUNT && i < this.chunks.length; i++) {
this.uploadNext();
}
Expand All @@ -204,17 +204,17 @@ ChunkUploader.prototype.uploadNext = function() {
var chunkNum = this.next, chunk = this.chunks[chunkNum];
assert(chunkNum < this.chunks.length);
this.next++;

var self = this;
var onComplete = function(error) {
if (error) {
if (error) {
console.log('Error uploading to ' + self.chunks[i].ref.toString() + ': ' + util.inspect(json));
console.error(error);
throw error;
throw error;
}

self.bar.tick();

if (chunkNum === self.chunks.length - 1) {
self.onComplete();
} else {
Expand Down

0 comments on commit c4a4214

Please sign in to comment.