1.0.0 • Published 10 years ago
collector-mongodb v1.0.0
mongodb
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 asstream.collection=collection
limit=1000
- maximum number of documents to insert at a timeinterval=1000
- minimum interval to insert
stream.write(doc)
Write an object to the collection.
stream.flush()
Force an insert into the collection.
1.0.0
10 years ago