1.0.0 • Published 9 years ago

collector-mongodb v1.0.0

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

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.