coloquent-test2
Version:
Library for retrieving model objects from a JSON-API, with a fluent syntax inspired by Laravel Eloquent.
42 lines • 2.04 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var PaginationSpec_1 = require("./PaginationSpec");
var QueryParam_1 = require("../QueryParam");
var OffsetBasedPaginationSpec = /** @class */ (function (_super) {
__extends(OffsetBasedPaginationSpec, _super);
function OffsetBasedPaginationSpec(pageOffsetParamName, pageLimitParamName, limit) {
var _this = _super.call(this) || this;
_this.queryParams = [];
_this.pageOffsetParamName = pageOffsetParamName;
_this.pageLimitParamName = pageLimitParamName;
_this.pageLimit = limit;
return _this;
}
OffsetBasedPaginationSpec.prototype.getPaginationParameters = function () {
if (this.pageOffset !== undefined) {
this.queryParams.push(new QueryParam_1.QueryParam("" + this.pageOffsetParamName, this.pageOffset));
this.queryParams.push(new QueryParam_1.QueryParam("" + this.pageLimitParamName, this.pageLimit));
}
return this.queryParams;
};
OffsetBasedPaginationSpec.prototype.setPage = function (page) {
page = Math.max(page, 1);
this.pageOffset = (page - 1) * this.pageLimit;
};
OffsetBasedPaginationSpec.prototype.setPageLimit = function (pageLimit) {
this.pageLimit = pageLimit;
};
return OffsetBasedPaginationSpec;
}(PaginationSpec_1.PaginationSpec));
exports.OffsetBasedPaginationSpec = OffsetBasedPaginationSpec;
//# sourceMappingURL=OffsetBasedPaginationSpec.js.map