MCPcopy Create free account
hub / github.com/Automattic/mongoose / QueryStream

Function QueryStream

lib/querystream.js:55–76  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

53 */
54
55function 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected