UNPKG

@blueleader07/typeorm

Version:

Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, MongoDB databases.

52 lines (50 loc) 1.85 kB
/** * View in the database represented in this class. */ export class View { // ------------------------------------------------------------------------- // Constructor // ------------------------------------------------------------------------- constructor(options) { this["@instanceof"] = Symbol.for("View"); if (options) { this.database = options.database; this.schema = options.schema; this.name = options.name; this.expression = options.expression; this.materialized = !!options.materialized; } } // ------------------------------------------------------------------------- // Public Methods // ------------------------------------------------------------------------- /** * Clones this table to a new table with all properties cloned. */ clone() { return new View({ database: this.database, schema: this.schema, name: this.name, expression: this.expression, materialized: this.materialized, }); } // ------------------------------------------------------------------------- // Static Methods // ------------------------------------------------------------------------- /** * Creates view from a given entity metadata. */ static create(entityMetadata, driver) { const options = { database: entityMetadata.database, schema: entityMetadata.schema, name: driver.buildTableName(entityMetadata.tableName, entityMetadata.schema, entityMetadata.database), expression: entityMetadata.expression, materialized: entityMetadata.tableMetadataArgs.materialized, }; return new View(options); } } //# sourceMappingURL=View.js.map