function QueryCursor(query, options) {
  Readable.call(this, { objectMode: true });

  this.cursor = null;
  this.query = query;
  this._transforms = options.transform ? [options.transform] : [];
  var _this = this;
  var model = query.model;
  model.hooks.execPre('find', query, function() {
    model.collection.find(query._conditions, options, function(err, cursor) {
      if (_this._error) {
        cursor.close(function() {});
        _this.listeners('error').length > 0 && _this.emit('error', _this._error);
      }
      if (err) {
        return _this.emit('error', err);
      }
      _this.cursor = cursor;
      _this.emit('cursor', cursor);
    });
  });
}
/**
 * A QueryCursor is a concurrency primitive for processing query results
 * one document at a time. A QueryCursor fulfills the [Node.js streams3 API](https://strongloop.com/strongblog/whats-new-io-js-beta-streams3/),
 * in addition to several other mechanisms for loading documents from MongoDB
 * one at a time.
 *
 * QueryCursors execute the model's pre find hooks, but **not** the model's
 * post find hooks.
 *
 * Unless you're an advanced user, do **not** instantiate this class directly.
 * Use [`Query#cursor()`](/docs/api.html#query_Query-cursor) instead.
 *
 * @param {Query} query
 * @param {Object} options query options passed to `.find()`
 * @inherits Readable
 * @event `cursor`: Emitted when the cursor is created
 * @event `error`: Emitted when an error occurred
 * @event `data`: Emitted when the stream is flowing and the next doc is ready
 * @event `end`: Emitted when the stream is exhausted
 * @api public
 */
A QueryCursor is a concurrency primitive for processing query results
one document at a time. A QueryCursor fulfills the [Node.js streams3 API],
in addition to several other mechanisms for loading documents from MongoDB
one at a time.

QueryCursors execute the model's pre find hooks, but **not** the model's
post find hooks.

Unless you're an advanced user, do **not** instantiate this class directly.


A QueryCursor is a concurrency primitive for processing query results one document at a time . A QueryCursor fulfills the [ Node . js streams3 API ] in addition to several other mechanisms for loading documents from MongoDB one at a time . QueryCursors execute the model ' s pre find hooks but ** not ** the model ' s post find hooks . Unless you ' re an advanced user do ** not ** instantiate this class directly .
function QueryCursor(query, options) {
  Readable.call(this, { objectMode: true });
  this.cursor = null;
  this.query = query;
  this._transforms = options.transform ? [options.transform] : [];
  var _this = this;
  var model = query.model;
  model.hooks.execPre('find', query, function() {
    model.collection.find(query._conditions, options, function(err, cursor) {
      if (_this._error) {
        cursor.close(function() {});
        _this.listeners('error').length > 0 && _this.emit('error', _this._error);
      }
      if (err) {
        return _this.emit('error', err);
      }
      _this.cursor = cursor;
      _this.emit('cursor', cursor);
    });
  });
}
function QueryCursor ( query , options ) { Readable . call ( this , { objectMode : true } ) ; this . cursor = null ; this . query = query ; this . _transforms = options . transform ? [ options . transform ] : [ ] ; var _this = this ; var model = query . model ; model . hooks . execPre ( 'find' , query , function ( ) { model . collection . find ( query . _conditions , options , function ( err , cursor ) { if ( _this . _error ) { cursor . close ( function ( ) { } ) ; _this . listeners ( 'error' ) . length > 0 && _this . emit ( 'error' , _this . _error ) ; } if ( err ) { return _this . emit ( 'error' , err ) ; } _this . cursor = cursor ; _this . emit ( 'cursor' , cursor ) ; } ) ; } ) ; }
A QueryCursor is a concurrency primitive for processing query results
 one document at a time.
A QueryCursor is a concurrency primitive for processing query results one document at a time .