mongo-stream-writer
v0.0.2
Published
Write streams directly to mongoDB
Downloads
2
Readme
mongo-stream-writer
Write streams directly to mongoDB
Installation
- npm i mongo-stream-writer
How to use
To use this module you need to provide a valid mongoDB string, collection to write your stream to and batch size as writer arguments.
Example:
import { mwriter } from 'mongo-stream-writer'
const infile = './data/file_with_json_objects.json'
const dbString = 'mongodb://foo:[email protected]/yourdb?authSource=yourdb'
const collection = 'foobarcollection'
const mongoStreamWriter = mwriter({ dbString: dbString, collection: collection, batchSize: 500 })
fs.createReadStream(infile)
.pipe(mongoStreamWriter)