louischatriot/nedb — pull request #239 by amcgee (2014-12-28 00:48:54+00:00)
Title: Stream functionality and MongoDB cursor resolution parity

Great work on this library, thanks for what you do!

The APIs for creating and modifying a cursor are equivalent in NeDB and MongoDB, in both you can execute `db.find({}).limit(4).skip(2)` and get the desired result.

However, when resolving the cursor and returning the underlying elements the APIs diverge. In NeDB you run `cursor.exec( function(err, res) {} )` whereas in MongoDB (to achieve the same result) you would execute `cursor.toArray(function(err, res) {} )` or create a stream with `cursor.stream()` and listen for stream events. See [this article from the mongo docs](http://mongodb.github.io/node-mongodb-native/api-articles/nodekoarticle1.html#time-to-query) for a good overview.

`cursor.exec` should be deprecated in favor of (or aliased to) the Mongo-compatible cursor resolution. Additionally, a cursor stream interface should be supported.

A basic implementation of this change is included in this pull request. This PR supports api parity but a full implementation of the feature should introduce streaming at a lower level so the driver doesn't need to hold the entire result set in memory.