UNPKG

@ossareh/typeorm

Version:

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

65 lines (63 loc) 2.24 kB
var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spread = (this && this.__spread) || function () { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; }; /** * Database's table unique constraint stored in this class. */ var TableUnique = /** @class */ (function () { // ------------------------------------------------------------------------- // Constructor // ------------------------------------------------------------------------- function TableUnique(options) { /** * Columns that contains this constraint. */ this.columnNames = []; this.name = options.name; this.columnNames = options.columnNames; } // ------------------------------------------------------------------------- // Public Methods // ------------------------------------------------------------------------- /** * Creates a new copy of this constraint with exactly same properties. */ TableUnique.prototype.clone = function () { return new TableUnique({ name: this.name, columnNames: __spread(this.columnNames) }); }; // ------------------------------------------------------------------------- // Static Methods // ------------------------------------------------------------------------- /** * Creates unique from the unique metadata object. */ TableUnique.create = function (uniqueMetadata) { return new TableUnique({ name: uniqueMetadata.name, columnNames: uniqueMetadata.columns.map(function (column) { return column.databaseName; }) }); }; return TableUnique; }()); export { TableUnique }; //# sourceMappingURL=TableUnique.js.map