Asymmetrical Signing
!NPM versionnpm-imagenpm-url
!Build statustravis-imagetravis-url
!Test coveragecodecov-imagecodecov-url
!Dependency Statusdavid-imagedavid-url
!Licenselicense-imagelicense-url
!Downloadsdownloads-imagedownloads-urlA writable stream that batches.
Example
const createBulk = require('bulk-insert')
const onError = (err) => {
if (err) console.error(err.stack || err)
}
const writable = createBulk({
limit: 500, // maximum # of documents to insert at one time
interval: '0.5s', // minimum interval between flushes,
onError,
flush (data) {
// `data` will be an array
kinesis.putRecords({
Records: data.map((x) => ({
Data: JSON.stringify(x),
PartitionKey: 'some_key'
})),
StreamName: 'some_stream_name'
}, onError)
}
})
writable.write({
some: 'data'
})
writable.write({
some: 'more data'
})
API
const writable = bulkInsert(options)
Options:limit<Integer>: 1000
- maximum # of documents to insert at one timeinterval<Number|String>: '300ms'
- minimum interval between flushes,onError<Function>
- optional function that handlesflush()
errorsflush<Function>
- a function with the signature(data<Array>) => {}