Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongoose Model.aggregate stream

Standard way of streaming appears to not work under Mongoose 4.4.2:

var stream = someModel.aggregate([]).batchSize(100).stream()

It throws both on batchSize and stream, saying they are undefined.

However the following seems to work:

var stream = someModel.aggregate([]).cursor({ batchSize: 100 }).exec();

It appears to behave in a similar way. Is this the right way to stream results from .aggregate()?

like image 830
Sebastian Nowak Avatar asked Dec 18 '22 19:12

Sebastian Nowak


1 Answers

No dear, you cannot directly create a bulk/batch you have to get some wrapper/transporter like cursor (as you already mentioned it). And it's the right way you're doing var stream = someModel.aggregate([]).cursor({ batchSize: 100 }).exec();

Thanks & Cheers

like image 118
Amulya Kashyap Avatar answered Jan 07 '23 04:01

Amulya Kashyap