Stream query results with the native mongoDB driver for node

前端 未结 2 1555
时光取名叫无心
时光取名叫无心 2021-01-14 19:46

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

相关标签:
2条回答
  • 2021-01-14 20:10

    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();
    
    0 讨论(0)
  • 2021-01-14 20:34

    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

    0 讨论(0)
提交回复
热议问题