Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bimedia-fr/mongo-bulk-writable

expose mongodb BulkOp as a writable stream
https://github.com/bimedia-fr/mongo-bulk-writable

Last synced: 8 days ago
JSON representation

expose mongodb BulkOp as a writable stream

Awesome Lists containing this project

README

        

# mongo-bulk-writable
expose mongodb BulkOp as a writable stream

## Install

> npm install --save mongo-bulk-writable

## Usage

Simple use case :

```js
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

```js
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);

```