UNPKG

refql

Version:

A Node.js and Deno library for composing and running SQL queries.

50 lines (49 loc) 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const _1 = require("."); const RQLNode_1 = require("../RQLTag/RQLNode"); const sql_1 = require("../SQLTag/sql"); const consts_1 = require("../common/consts"); const PropType_1 = require("./PropType"); const type = "refql/SQLProp"; const prototype = Object.assign({}, RQLNode_1.rqlNodePrototype, PropType_1.propTypePrototype, { constructor: SQLProp, [consts_1.refqlType]: type, arrayOf: _1.nullable, nullable: _1.nullable, eq: (0, _1.eq)(), notEq: (0, _1.eq)(true), isNull: (0, _1.isNull)(), notIsNull: (0, _1.isNull)(true), like: (0, _1.like)(true), notLike: (0, _1.like)(true, true), iLike: (0, _1.like)(), notILike: (0, _1.like)(false, true), in: (0, _1.whereIn)(), notIn: (0, _1.whereIn)(true), gt: (0, _1.ord)(">"), gte: (0, _1.ord)(">="), lt: (0, _1.ord)("<"), lte: (0, _1.ord)("<="), asc: (0, _1.dir)(), desc: (0, _1.dir)(true), omit: _1.omit, or: (0, _1.logic)("or"), and: (0, _1.logic)("and"), interpret }); function SQLProp(as, col) { let prop = Object.create(prototype); prop.as = as; prop.col = col; prop.operations = []; prop.isOmitted = false; return prop; } function interpret() { return (0, sql_1.sqlX) `(${this.col})`; } SQLProp.isSQLProp = function (x) { return x != null && x[consts_1.refqlType] === type; }; exports.default = SQLProp;