typecql
Version:
ORM for CQL databases.
31 lines • 1.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RegisteredEntities = void 0;
const typecql_decorator_functions_1 = require("../../meta/typecql.decorator.functions");
class RegisteredEntities {
static addRepository(entity, repository, connectionName = 'default') {
const tableName = (0, typecql_decorator_functions_1.getTableName)(entity);
if (!tableName) {
throw new Error('[TYPECQL] - No entity table name provided!');
}
const connectionObj = this.connections.get(connectionName);
if (!connectionObj) {
throw new Error('[TYPECQL] - No connection was provided!');
}
connectionObj.set(tableName, repository);
}
static getRepository(entity, connectionName = 'default') {
const tableName = (0, typecql_decorator_functions_1.getTableName)(entity);
if (!tableName) {
throw new Error('[TYPECQL] - No entity table name provided!');
}
const connectionObj = this.connections.get(connectionName);
if (!connectionObj) {
throw new Error('[TYPECQL] - No connection was provided!');
}
return connectionObj.get(tableName);
}
}
exports.RegisteredEntities = RegisteredEntities;
RegisteredEntities.connections = new Map();
//# sourceMappingURL=RegisteredEntities.js.map