find-in-batches
A flow control helper method that invokes a forEach function for each element that was returned in the passed find method. This is a wrapper around async.js and uses simple pagination to do its magic.
API
findInBatches.each([options], findMethod, forEach, callback)
findInBatches.batch([options], findMethod, forBatch, callback)
findInBatches.all([options], findMethod, callback)
findInBatches.each
var request = var findInBatches = var options = offset: 0 // a default offset batchSize: 50 // this gets passed to the findMethod as limit maximum: Infinity // maximum count of documents that get loaded concurrency: Infinity // how many forEach methods should run simultaneously findInBatches; { // options = {offset: 0, limit: 50, page: 1} // on first search // options = {offset: 50, limit: 50, page: 2} // on second iteration var url = 'http://maps.gelbeseiten.de' url += '/yp/subscriberlist_ajaxAction.yp?urlSegmentSubjectString=starbucks' url += '&recfrom=' + optionsoffset + '&reccount=' + optionslimit request} // forEach gets invoked for each element that gets returned in the findMethod.// e.g. if the findMethod would return `callback(null, [{id: 1, name: 'one'}, {id: 2, name: 'two'}])`,// the entry would equal `{id: 1, name: 'one'}`{ entryaddress = entryaddress || {} entryaddressstreet = entryaddressstreet || {} console }