zents
Version:
ZenTS is a Node.js & TypeScript MVC-Framework for building rich web applications, released as free and open-source software under the MIT License. It is designed for building web applications with modern tools and design patterns.
35 lines • 1.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RepositoryAction = void 0;
const types_1 = require("../../types");
const AbstractAction_1 = require("./AbstractAction");
class RepositoryAction extends AbstractAction_1.AbstractAction {
run(instance, method) {
if (!Reflect.hasMetadata(types_1.REFLECT_METADATA.DATABASE_REPOSITORY, instance, method)) {
return [];
}
const connection = this.injector.context.getConnection();
const metadata = Reflect.getMetadata(types_1.REFLECT_METADATA.DATABASE_REPOSITORY, instance, method);
const parameters = metadata.map((meta) => {
let value = null;
switch (meta.repositoryType) {
case types_1.REPOSITORY_TYPE.REPOSITORY:
value = connection.getRepository(meta.entity);
break;
case types_1.REPOSITORY_TYPE.TREE:
value = connection.getTreeRepository(meta.entity);
break;
case types_1.REPOSITORY_TYPE.CUSTOM:
value = connection.getCustomRepository(meta.entity);
break;
}
return {
index: meta.index,
value,
};
});
return parameters;
}
}
exports.RepositoryAction = RepositoryAction;
//# sourceMappingURL=RepositoryAction.js.map