mongo-bulk-writable
v1.1.0
Published
expose mongodb BulkOp as a writable stream
Downloads
4
Readme
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);