UNPKG

sedk-mysql

Version:
50 lines 1.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Schema = void 0; const util_1 = require("../util"); class Schema { constructor(data) { var _a; this.data = data; this.mName = (_a = data.name) !== null && _a !== void 0 ? _a : 'public'; this.mTables = data.tables; const tableArray = []; Object.values(data.tables).forEach(it => { tableArray.push(it); it.schema = this; }); this.tableArray = tableArray; } set database(database) { if (this.mDatabase === undefined) this.mDatabase = database; else throw new Error('Database can only be assigned one time'); } get database() { if (this.mDatabase === undefined) throw new Error('Database is undefined'); return this.mDatabase; } get name() { return this.mName; } get fqName() { return `\`${(0, util_1.escapeBackTick)(this.mName)}\``; } get tables() { return this.mTables; } /** Alias to get tables() */ get t() { return this.tables; } isTableExist(table) { return this.tableArray.includes(table); } isColumnExist(column) { return this.tableArray.some(it => it.isColumnExist(column)); } } exports.Schema = Schema; //# sourceMappingURL=Schema.js.map