sedk-mysql
Version:
Simple SQL builder and validator for MySQL
29 lines • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.LimitWithOffsetStep = void 0;
const errors_1 = require("../../errors");
const BaseLimitStep_1 = require("./BaseLimitStep");
class LimitWithOffsetStep extends BaseLimitStep_1.BaseLimitStep {
constructor(prevStep, offset, limit, asBinder = false) {
super(prevStep);
if (!Number.isFinite(offset) || offset < 0 || !Number.isInteger(offset)) {
throw new errors_1.InvalidOffsetValueError(offset);
}
if (!Number.isFinite(limit) || limit < 0 || !Number.isInteger(limit)) {
throw new errors_1.InvalidLimitValueError(limit);
}
if (asBinder) {
this.offset = this.binderStore.getBinder(offset);
this.limit = this.binderStore.getBinder(limit);
}
else {
this.offset = offset;
this.limit = limit;
}
}
getStepStatement() {
return `LIMIT ${this.offset}, ${this.limit}`;
}
}
exports.LimitWithOffsetStep = LimitWithOffsetStep;
//# sourceMappingURL=LimitWithOffsetStep.js.map