LearnBoost/mongoose — Issue #614: make query.each more like a stream?
Author: aheckmann
Created: 2011-11-15 16:59:35+00:00
State: open

Maybe?

``` javascript
var stream = Thing.find(...).stream();
stream.on('error', function (err) {}); // the stream is now closed
stream.on('end', function () {}); // the stream is now closed
stream.on('doc', function (doc) {
// this.close() - stops/closes the cursor
})
```

old

``` javascript
Thing.find(...).each(function (err, doc [, next]) {
if (err) // the cursor closed
if (doc) ...
// next() - for manual iteration but there is no way to close the underlying cursor
});