UNPKG

sedk-postgres

Version:

Simple SQL builder and validator

63 lines 2.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SelectWhereOrStep = exports.SelectWhereAndStep = exports.SelectWhereStep = void 0; const OffsetStep_1 = require("./OffsetStep"); const LimitStep_1 = require("./LimitStep"); const OrderByStep_1 = require("./OrderByStep"); const ConditionStep_1 = require("../ConditionStep"); const BaseStep_1 = require("../BaseStep"); const GroupByStep_1 = require("./GroupByStep"); const ReturningStep_1 = require("../ReturningStep"); class SelectConditionStep extends ConditionStep_1.ConditionStep { and(cond1, op1, cond2, op2, cond3) { const whereParts = []; BaseStep_1.BaseStep.addConditionParts(whereParts, cond1, op1, cond2, op2, cond3); return new SelectWhereAndStep(this, whereParts); } or(cond1, op1, cond2, op2, cond3) { const whereParts = []; BaseStep_1.BaseStep.addConditionParts(whereParts, cond1, op1, cond2, op2, cond3); return new SelectWhereOrStep(this, whereParts); } groupBy(...groupByItems) { return new GroupByStep_1.GroupByStep(this, groupByItems); } orderBy(...orderByItems) { return new OrderByStep_1.OrderByStep(this, orderByItems); } limit(n) { return new LimitStep_1.LimitStep(this, n); } limit$(n) { return new LimitStep_1.LimitStep(this, n, true); } offset(n) { return new OffsetStep_1.OffsetStep(this, n); } offset$(n) { return new OffsetStep_1.OffsetStep(this, n, true); } //TODO: check if we should have returning as this is path of select returning(...items) { return new ReturningStep_1.ReturningStep(this, items); } } class SelectWhereStep extends SelectConditionStep { constructor(prevStep, whereParts) { super('WHERE', prevStep, whereParts); } } exports.SelectWhereStep = SelectWhereStep; class SelectWhereAndStep extends SelectConditionStep { constructor(prevStep, whereParts) { super('AND', prevStep, whereParts); } } exports.SelectWhereAndStep = SelectWhereAndStep; class SelectWhereOrStep extends SelectConditionStep { constructor(prevStep, whereParts) { super('OR', prevStep, whereParts); } } exports.SelectWhereOrStep = SelectWhereOrStep; //# sourceMappingURL=SelectConditionStep.js.map