perf(savedMessages): save a db lookup and message content decryption by building the returned entity manually after creation

This commit is contained in:
Dragory 2021-10-09 11:49:34 +03:00
parent f582640e8e
commit e5389c0e55
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
2 changed files with 10 additions and 1 deletions

View file

@ -0,0 +1,7 @@
export function buildEntity<T extends any>(Entity: new () => T, data: Partial<T>): T {
const instance = new Entity();
for (const [key, value] of Object.entries(data)) {
instance[key] = value;
}
return instance;
}