UNPKG

@sequeljs/ast

Version:

A SQL AST manager for JavaScript

35 lines 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Attribute_1 = require("./attributes/Attribute"); const TableAlias_1 = require("./nodes/TableAlias"); class Table { get tableName() { return this.name; } constructor(name, as = null, // eslint-disable-next-line @typescript-eslint/no-explicit-any typeCaster = null) { this.name = name; this.typeCaster = typeCaster; let tableAlias = as; if (as === name || (as instanceof TableAlias_1.default && as.name === name)) { tableAlias = null; } this.tableAlias = tableAlias; } alias(name = null) { return new TableAlias_1.default(this, name !== null && name !== void 0 ? name : `${this.name}_2`); } get(name) { return new Attribute_1.default(this, name); } /* TypeCaster */ isAbleToTypeCast() { return !!this.typeCaster; } typeCastForDatabase(attributeName, value) { return this.typeCaster.typeCastForDatabase(attributeName, value); } } exports.default = Table; //# sourceMappingURL=Table.js.map