Skip to content Skip to sidebar Skip to footer

Stream Query Results With The Native Mongodb Driver For Node

I have 100,000 records in a mongoDB collection and trying to retrieve them in a node.js application using the native driver. I follow the example in MongoDB doc for CursorStream bu

Solution 1:

It looks like the problem is solved by setting a batch size in the Cursor Stream:

var stream = myCollection.find(query, fields, options).batchSize(10000).stream();

Solution 2:

You might want to try setImmediate instead of setTimeout, to ensure outstanding IO operations can be flushed. See also https://github.com/ZJONSSON/streamz/issues/1

Post a Comment for "Stream Query Results With The Native Mongodb Driver For Node"