feat: consolidate entities create

This was done to give better typings to the function signatures of entities `create` methods.
It also ensures that each field that should be set to `null` is set to `null` and doesn't leave that up to the typeorm handlers.

See: #1641
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2021-09-25 11:50:28 +02:00 committed by David Mehren
parent bd902e50d1
commit d0b8e4cd36
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
14 changed files with 89 additions and 40 deletions

View file

@ -101,11 +101,15 @@ export class Identity {
user: User,
providerType: ProviderType,
syncSource = false,
): Identity {
): Omit<Identity, 'id' | 'createdAt' | 'updatedAt'> {
const newIdentity = new Identity();
newIdentity.user = user;
newIdentity.providerType = providerType;
newIdentity.providerName = null;
newIdentity.syncSource = syncSource;
newIdentity.providerUserId = null;
newIdentity.oAuthAccessToken = null;
newIdentity.passwordHash = null;
return newIdentity;
}
}