@ossareh/typeorm
Version:
Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, MongoDB databases.
77 lines (75 loc) • 2.7 kB
JavaScript
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 index stored in this class.
*/
var TableIndex = /** @class */ (function () {
// -------------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------------
function TableIndex(options) {
/**
* Columns included in this index.
*/
this.columnNames = [];
this.name = options.name;
this.columnNames = options.columnNames;
this.isUnique = options.isUnique;
this.isSpatial = options.isSpatial;
this.isFulltext = options.isFulltext;
this.where = options.where;
}
// -------------------------------------------------------------------------
// Public Methods
// -------------------------------------------------------------------------
/**
* Creates a new copy of this index with exactly same properties.
*/
TableIndex.prototype.clone = function () {
return new TableIndex({
name: this.name,
columnNames: __spread(this.columnNames),
isUnique: this.isUnique,
isSpatial: this.isSpatial,
isFulltext: this.isFulltext,
where: this.where
});
};
// -------------------------------------------------------------------------
// Static Methods
// -------------------------------------------------------------------------
/**
* Creates index from the index metadata object.
*/
TableIndex.create = function (indexMetadata) {
return new TableIndex({
name: indexMetadata.name,
columnNames: indexMetadata.columns.map(function (column) { return column.databaseName; }),
isUnique: indexMetadata.isUnique,
isSpatial: indexMetadata.isSpatial,
isFulltext: indexMetadata.isFulltext,
where: indexMetadata.where
});
};
return TableIndex;
}());
export { TableIndex };
//# sourceMappingURL=TableIndex.js.map