dist/model.js
function queryArrayQuery() {
  var _this = this;

  var queryOpts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

  var opts = Object.assign({}, this.baseOpts, queryOpts);

  if (this.isPaged) {
    opts.page = opts.page || 1;
  }

  if (this.isBusy) {
    if (util.eq(opts, this.currentOpts)) {
      return this;
    }

    if (!this.__queued__) {
      this.__promise__ = this.__promise__.then(function () {
        _this.query(_this.__queued__);
        _this.__queued__ = undefined;
        return _this.__promise__;
      });
    }

    this.__queued__ = opts;
  } else {
    this.isBusy = true;
    this.currentOpts = opts;
    this.__promise__ = wrapPromise(this.__modelClass__._callMapper('query', [opts]).then(function (result) {
      var results = Array.isArray(result) ? result : result.results;
      var meta = Array.isArray(result) ? {} : result.meta;

      _this.isBusy = false;
      _this.meta = meta;
      _this.error = undefined;

      if (!results) {
        throw new Error(_this + "#query: mapper failed to return any results");
      }

      if (_this.isPaged && typeof meta.totalCount !== 'number') {
        throw new Error(_this + "#query: mapper failed to return total count for paged query");
      }

      try {
        var models = _this.__modelClass__.loadAll(results);

        if (_this.isPaged) {
          _this.length = meta.totalCount;
          _this.splice.apply(_this, [(opts.page - 1) * _this.baseOpts.pageSize, models.length].concat(models));
        } else {
          _this.replace(models);
        }
      } catch (e) {
        console.error(e);throw e;
      }
    }, function (e) {
      _this.isBusy = false;
      _this.error = e;
      return Promise.reject(e);
    }));
  }

  return this;
}
function queryArrayQuery() {
  var _this = this;

  var queryOpts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

  var opts = Object.assign({}, this.baseOpts, queryOpts);

  if (this.isPaged) {
    opts.page = opts.page || 1;
  }

  if (this.isBusy) {
    if (util.eq(opts, this.currentOpts)) {
      return this;
    }

    if (!this.__queued__) {
      this.__promise__ = this.__promise__.then(function () {
        _this.query(_this.__queued__);
        _this.__queued__ = undefined;
        return _this.__promise__;
      });
    }

    this.__queued__ = opts;
  } else {
    this.isBusy = true;
    this.currentOpts = opts;
    this.__promise__ = wrapPromise(this.__modelClass__._callMapper('query', [opts]).then(function (result) {
      var results = Array.isArray(result) ? result : result.results;
      var meta = Array.isArray(result) ? {} : result.meta;

      _this.isBusy = false;
      _this.meta = meta;
      _this.error = undefined;

      if (!results) {
        throw new Error(_this + "#query: mapper failed to return any results");
      }

      if (_this.isPaged && typeof meta.totalCount !== 'number') {
        throw new Error(_this + "#query: mapper failed to return total count for paged query");
      }

      try {
        var models = _this.__modelClass__.loadAll(results);

        if (_this.isPaged) {
          _this.length = meta.totalCount;
          _this.splice.apply(_this, [(opts.page - 1) * _this.baseOpts.pageSize, models.length].concat(models));
        } else {
          _this.replace(models);
        }
      } catch (e) {
        console.error(e);throw e;
      }
    }, function (e) {
      _this.isBusy = false;
      _this.error = e;
      return Promise.reject(e);
    }));
  }

  return this;
}
Internal: Provides the implementation of the query array's `query` method.