@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
35 lines • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PersistenceCache = PersistenceCache;
const PersistenceContext_1 = require("../PersistenceContext");
const di_1 = require("@nodeboot/di");
/**
* Decorator to register a custom QueryResultCache implementation for persistence query caching.
*
* This decorator applies dependency injection decoration and sets the provided class
* as the active query cache provider in the persistence context.
*
* @template T - A class extending TypeORM's QueryResultCache.
* @returns {ClassDecorator} The class decorator function.
*
* @example
* ```ts
* import {PersistenceCache} from "@nodeboot/starter-persistence";
* import {QueryResultCache} from "typeorm/cache/QueryResultCache";
*
* @PersistenceCache()
* class CustomQueryCache extends QueryResultCache {
* // custom cache implementation
* }
* ```
*
* @author Manuel Santos <https://github.com/manusant>
*/
function PersistenceCache() {
return (target) => {
// Inject dependencies if DI container is configured
(0, di_1.decorateDi)(target);
PersistenceContext_1.PersistenceContext.get().queryCache = target;
};
}
//# sourceMappingURL=PersistenceCache.js.map