@sequeljs/ast
Version:
A SQL AST manager for JavaScript
42 lines • 1.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const Node_1 = require("./Node");
const Range_1 = require("./Range");
const Rows_1 = require("./Rows");
const SQLLiteral_1 = require("./SQLLiteral");
class Window extends Node_1.default {
constructor() {
super(...arguments);
this.framing = null;
this.orders = [];
this.partitions = [];
}
frame(expr) {
this.framing = expr;
return this.framing;
}
order(...expr) {
this.orders.push(...expr.map((x) => (typeof x === 'string' ? new SQLLiteral_1.default(x) : x)));
return this;
}
partition(...expr) {
this.partitions.push(...expr.map((x) => (typeof x === 'string' ? new SQLLiteral_1.default(x) : x)));
return this;
}
range(expr = null) {
const range = new Range_1.default(expr);
if (!this.framing) {
this.frame(range);
}
return range;
}
rows(expr = null) {
const rows = new Rows_1.default(expr);
if (!this.framing) {
this.frame(rows);
}
return rows;
}
}
exports.default = Window;
//# sourceMappingURL=Window.js.map