1.1.0 • Published 8 years ago

mongo-bulk-writable v1.1.0

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

mongo-bulk-writable

expose mongodb BulkOp as a writable stream

Install

npm install --save mongo-bulk-writable

Usage

Simple use case :

var BulkWritable = require('mongo-bulk-writable');
var col; // get a collection object from driver
var writable = new BulkWritable(col.initializeOrderedBulkOp(), function write(chunk, next) {
  this.bulk.insert(chunk);
  next();
});
// pipe it
req.pipe(writable);

Or

var BulkWritable = require('mongo-bulk-writable');
var col; // get a collection object from driver
var writable = new BulkWritable(col.initializeUnorderedBulkOp(), function write(chunk, next) {
  this.bulk.find( { status: "P" } ).update( { $set: { comment: chunk.comment} } );
  next();
});
// pipe it
req.pipe(writable);