save array

This commit is contained in:
tamaina 2024-03-10 16:00:25 +00:00
parent 9bfa38e601
commit e2b574a97c
1 changed files with 6 additions and 8 deletions

View File

@ -396,18 +396,16 @@ export class ApPersonService implements OnModuleInit {
})); }));
if (person.publicKey) { if (person.publicKey) {
const keys = new Map<string, IKey>([ const publicKeys = new Map<string, IKey>([
...(person.additionalPublicKeys ? person.additionalPublicKeys.map(key => [key.id, key] as const) : []), ...(person.additionalPublicKeys ? person.additionalPublicKeys.map(key => [key.id, key] as const) : []),
[person.publicKey.id, person.publicKey], [person.publicKey.id, person.publicKey],
]); ]);
for (const key of keys.values()) { await this.userPublickeysRepository.save(Array.from(publicKeys.values(), key => ({
await transactionalEntityManager.save(new MiUserPublickey({
keyId: key.id, keyId: key.id,
userId: user.id, userId: user!.id,
keyPem: key.publicKeyPem, keyPem: key.publicKeyPem,
})); })));
}
} }
}); });
} catch (e) { } catch (e) {