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:
parent
0b337a13a4
commit
b7c7e002eb
16 changed files with 310 additions and 147 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue