mongoose-querystream-worker

Execute an async function per document in a streamed query, pausing the stream when a concurrency limit is saturated

npm install mongoose-querystream-worker
2 downloads in the last day
11 downloads in the last week
30 downloads in the last month

mongoose-querystream-worker build status

Execute an async function per document in a streamed query, pausing the stream when a concurrency limit is saturated. Think async.queue but for Mongoose QueryStreams. Built on top of stream-worker.

require('mongoose-querystream-worker');

Model.find().stream().concurrency(n).work(
  function (doc, done) {
   /* ... work with the doc ... */ 
  }, 
  function (err) {
   /* ...  all workers have finished ... */
  }
});
npm loves you