Skip to content

collectors/mongodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Batched MongoDB inserts as a writable stream

Resources

License

Stars

Watchers

Forks

Packages

No packages published