code: function(callback, options = {}) {
          if (this._order || this._skip || this._limit >= 0) {
            var error = new Error(
              'Cannot iterate on a query with sort, skip, or limit.'
            );
            return Promise.reject(error);
          }
  
          var query = new AV.Query(this.objectClass);
          // We can override the batch size from the options.
          // This is undocumented, but useful for testing.
          query._limit = options.batchSize || 100;
          query._where = _.clone(this._where);
          query._include = _.clone(this._include);
  
          query.ascending('objectId');
  
          var finished = false;
          return Promise._continueWhile(
            function() {
              return !finished;
            },
            function() {
              return query.find(options).then(function(results) {
                var callbacksDone = Promise.resolve();
                _.each(results, function(result) {
                  callbacksDone = callbacksDone.then(function() {
                    return callback(result);
                  });
                });
  
                return callbacksDone.then(function() {
                  if (results.length >= query._limit) {
                    query.greaterThan('objectId', results[results.length - 1].id);
                  } else {
                    finished = true;
                  }
                });
              });
            }
          );
        }
docs: Iterates over each result of a query, calling a callback for each one. If
  the callback returns a promise, the iteration will not continue until
  that promise has been fulfilled. If the callback returns a rejected
  promise, then iteration will stop with that error. The items are
  processed in an unspecified order. The query may not have any sort order,
  and may not use limit or skip.
  @param callback {Function} Callback that will be called with each result
  of the query.
  @return {Promise} A promise that will be fulfilled once the
  iteration has completed.