3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-15 14:15:03 +00:00

perf: move encryption/decryption to a separate thread

This commit is contained in:
Dragory 2021-10-09 14:21:23 +03:00
parent 0b337a13a4
commit b7c7e002eb
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
16 changed files with 310 additions and 147 deletions

View file

@ -1,4 +1,6 @@
export class BaseRepository {
import { asyncMap } from "../utils/async";
export class BaseRepository<TEntity extends unknown = unknown> {
private nextRelations: string[];
constructor() {
@ -27,4 +29,26 @@ export class BaseRepository {
this.nextRelations = [];
return relations;
}
protected async _processEntityFromDB(entity) {
// No-op, override in repository
return entity;
}
protected async _processEntityToDB(entity) {
// No-op, override in repository
return entity;
}
protected async processEntityFromDB<T extends TEntity | undefined>(entity: T): Promise<T> {
return this._processEntityFromDB(entity);
}
protected async processMultipleEntitiesFromDB<TArr extends TEntity[]>(entities: TArr): Promise<TArr> {
return asyncMap(entities, (entity) => this.processEntityFromDB(entity)) as Promise<TArr>;
}
protected async processEntityToDB<T extends Partial<TEntity>>(entity: T): Promise<T> {
return this._processEntityToDB(entity);
}
}