UNPKG

refql

Version:

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

26 lines (25 loc) 717 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const consts_1 = require("../common/consts"); const type = "refql/Ref"; const prototype = { [consts_1.refqlType]: type, constructor: RefField, toString }; function RefField(name, as) { let ref = Object.create(prototype); ref.name = name; ref.as = as; return ref; } function toString() { return `${this.name} ${this.as}`; } RefField.isRefField = function (x) { return x != null && x[consts_1.refqlType] === type; }; RefField.refFieldOf = function (as) { return (table, kw, ref) => RefField(`${table.name}.${ref.trim()}`, `${(as).replace(/_/g, "").toLowerCase()}${kw}`); }; exports.default = RefField;