Mongoose Stream JSON Data Mongoose Stream JSON Data mongoose mongoose

Mongoose Stream JSON Data


Actually you can use directly the pipe method as following

var mq = DeviceData.find().lean().cursor().pipe(yourWritableStream);

or from my recipes

DeviceData.find({})    .lean()    .cursor()    .pipe(new Writable({      objectMode: true,      write(data, encoding, next) {        // do something with your data        // call next    }))    .on('finish', () => {      // you can do something when the stream ends    })