UNPKG

@sequeljs/ast

Version:

A SQL AST manager for JavaScript

39 lines 1.04 kB
import Node from './Node'; import Range from './Range'; import Rows from './Rows'; import SQLLiteral from './SQLLiteral'; export default class Window extends Node { 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(x) : x))); return this; } partition(...expr) { this.partitions.push(...expr.map((x) => (typeof x === 'string' ? new SQLLiteral(x) : x))); return this; } range(expr = null) { const range = new Range(expr); if (!this.framing) { this.frame(range); } return range; } rows(expr = null) { const rows = new Rows(expr); if (!this.framing) { this.frame(rows); } return rows; } } //# sourceMappingURL=Window.js.map