collector-mongodb

1.0.0 • Public • Published

mongodb

NPM version Build status Test coverage Dependency Status License Downloads Gittip

A writable stream that batches MongoDB inserts.

API

const Collector_MongoDB = require('collector-mongodb')
 
const stream = Collector_MongoDB({
  limit: 100, // insert at most 100 documents at a time
  interval: 100, // insert at least every 100ms
})
 
stream.collection = <your mongodb collection>
 
stream.write({
  key: 'value'
})

var stream = Collector_MongoDB([options])

Create a writable stream. Options:

  • collection - collection to write to. You can also set this asynchronously as stream.collection=collection
  • limit=1000 - maximum number of documents to insert at a time
  • interval=1000 - minimum interval to insert

stream.write(doc)

Write an object to the collection.

stream.flush()

Force an insert into the collection.

Readme

Keywords

Package Sidebar

Install

npm i collector-mongodb

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • jongleberry