javascript - Stream query results with the native mongoDB driver for node -


i have 100,000 records in mongodb collection , trying retrieve them in node.js application using native driver.

i follow example in mongodb doc cursorstream error:

rangeerror: maximum call stack size exceeded 

before error many of these:

(node) warning: recursive process.nexttick detected. break in next version of node. please use setimmediate recursive deferral. 

here code:

var query = {...}; var fields = {...}; var options = {     // "limit": 10     //"skip": 10,     //"sort": title }  var stream = mycollection.find(query, fields, options).stream(); //  stream.pause(); var results = []; stream.on('data', function (item){     results.push(item);     stream.pause();     // restart stream after 1 miliscecond     settimeout(function() {         stream.resume();     }, 1); });  stream.on('close'..... 

the error occurs when don't define listener 'data' event. doesn't occur if pause stream right after creation.

the mongod version v2.4.1 node driver version 1.2.x

any help/hint appreciated.

it looks problem solved setting batch size in cursor stream:

var stream = mycollection.find(query, fields, options).batchsize(10000).stream(); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -