1.1.1 • Published 9 years ago

mongodump-stream v1.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

Mongo Dump Streaming Utilities

Obtain a stream object from mongo's export utility.

Heavily based off timisbusy/dumpstr

Documentation

var mds = require('mongodump-stream');

API

mds.slurp.binary(uri, collection)

Get a binary stream of your collection (mongodump).

mds.slurp.text(uri, collection)

Get a textual stream of your collection (mongoexport).

mds.dump.s3(key, stream, awsConf)

Write an object named key to an S3 bucket using the data in stream. awsConf must contain the properties key, secret, and bucket.

mds.dump.fs.file(stream, path)

Dump stream into path.

Example

var mds = require('mongodump-stream');

var mongoUrl = 'mongodb://localhost:27017/YOUR-DB';
var mongoCollection = 'YOUR-COLLECTION';

var now = Date.now();

var fname = mongoCollection + '-' + now + '.bson';

var stream = mds.slurp.binary(mongoUrl, mongoCollection);

mds.dump.s3(fname, stream, {
  key: process.env.AWS_ACCESS,
  secret: process.env.AWS_SECRET,
  bucket: process.env.AWS_S3_BUCKET
}).then(/* YOUR CALLBACKS */);


//
// You could also write it to a file
//
mds.dump.fs.file(stream, fname);