UNPKG

refql

Version:

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

34 lines (33 loc) 1.18 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const consts_1 = require("../common/consts"); const Table_1 = require("../Table"); const PropType_1 = require("./PropType"); const validateRefInput_1 = __importDefault(require("./validateRefInput")); const type = "refql/RefProp"; const prototype = Object.assign({}, PropType_1.propTypePrototype, { constructor: RefProp, [consts_1.refqlType]: type, nullable }); function RefProp(as, tableId, rel, refInput, isNullable) { (0, validateRefInput_1.default)(refInput); let refProp = Object.create(prototype); refProp.tableId = tableId; refProp.rel = rel; refProp.as = as; refProp.child = (0, Table_1.TableX)(tableId, []); refProp.refInput = refInput; refProp.isNullable = isNullable; return refProp; } function nullable() { return RefProp(this.as, this.tableId, this.rel, this.refInput, true); } RefProp.isRefProp = function (x) { return x != null && x[consts_1.refqlType] === type; }; exports.default = RefProp;