@nestjs/typeorm
Version:
TypeORM for NestJS: connections and repositories through dependency injection, entities, transactions and multiple databases.
22 lines (21 loc) • 744 B
JavaScript
import { getDataSourceName } from './common/typeorm.utils.js';
export class EntitiesMetadataStorage {
static storage = new Map();
static addEntitiesByDataSource(dataSource, entities) {
const dataSourceName = getDataSourceName(dataSource);
let collection = this.storage.get(dataSourceName);
if (!collection) {
collection = [];
this.storage.set(dataSourceName, collection);
}
entities.forEach((entity) => {
if (collection.includes(entity)) {
return;
}
collection.push(entity);
});
}
static getEntitiesByDataSource(dataSource) {
return this.storage.get(getDataSourceName(dataSource)) || [];
}
}