@nodeboot/starter-persistence
Version:
Nodeboot starter package for persistence. Supports data access layer auto-configuration providing features like database initialization, consistency check, entity mapping, repository pattern, transactions, paging, migrations, persistence listeners, persis
32 lines • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntityEventSubscriber = EntityEventSubscriber;
const typeorm_1 = require("typeorm");
const PersistenceContext_1 = require("../PersistenceContext");
/**
* Decorator to mark a class as a TypeORM Entity Subscriber and register it
* within the PersistenceContext for event handling.
*
* Use this decorator on classes implementing EntitySubscriberInterface
* to automatically subscribe to entity events in the persistence layer.
*
* @template T - A class type extending EntitySubscriberInterface.
* @returns {ClassDecorator} The class decorator function.
*
* @example
* ```ts
* @EntityEventSubscriber()
* class UserSubscriber implements EntitySubscriberInterface<User> {
* // implementation...
* }
* ```
*
* @author Manuel Santos <https://github.com/manusant>
*/
function EntityEventSubscriber() {
return (target) => {
(0, typeorm_1.EventSubscriber)()(target);
PersistenceContext_1.PersistenceContext.get().eventSubscribers.push(target);
};
}
//# sourceMappingURL=EntityEventSubscriber.js.map