UNPKG

@sequeljs/ast

Version:

A SQL AST manager for JavaScript

33 lines 1 kB
import Attribute from './attributes/Attribute'; import TableAlias from './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 && as.name === name)) { tableAlias = null; } this.tableAlias = tableAlias; } alias(name = null) { return new TableAlias(this, name !== null && name !== void 0 ? name : `${this.name}_2`); } get(name) { return new Attribute(this, name); } /* TypeCaster */ isAbleToTypeCast() { return !!this.typeCaster; } typeCastForDatabase(attributeName, value) { return this.typeCaster.typeCastForDatabase(attributeName, value); } } export default Table; //# sourceMappingURL=Table.js.map