* Provides a Node.js 0.8 style [ReadStream](http://nodejs.org/docs/v0.8.21/api/stream.html#stream_readable_stream) interface for Queries. * * var stream = Model.find().stream(); * * stream.on('data', function (doc) { * // do something with the mongoose document * }).on('error
(query, options)
| 53 | */ |
| 54 | |
| 55 | function QueryStream(query, options) { |
| 56 | Stream.call(this); |
| 57 | |
| 58 | this.query = query; |
| 59 | this.readable = true; |
| 60 | this.paused = false; |
| 61 | this._cursor = null; |
| 62 | this._destroyed = null; |
| 63 | this._fields = null; |
| 64 | this._buffer = null; |
| 65 | this._inline = T_INIT; |
| 66 | this._running = false; |
| 67 | this._transform = options && typeof options.transform === 'function' |
| 68 | ? options.transform |
| 69 | : K; |
| 70 | |
| 71 | // give time to hook up events |
| 72 | var _this = this; |
| 73 | process.nextTick(function() { |
| 74 | _this._init(); |
| 75 | }); |
| 76 | } |
| 77 | |
| 78 | /*! |
| 79 | * Inherit from Stream |
nothing calls this directly
no outgoing calls
no test coverage detected