mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-30 06:45:47 -04:00
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:
parent
bd902e50d1
commit
d0b8e4cd36
14 changed files with 89 additions and 40 deletions
|
@ -79,13 +79,19 @@ export class User {
|
|||
public static create(
|
||||
username: string,
|
||||
displayName: string,
|
||||
): Pick<
|
||||
User,
|
||||
'username' | 'displayName' | 'ownedNotes' | 'authTokens' | 'identities'
|
||||
> {
|
||||
): Omit<User, 'id' | 'createdAt' | 'updatedAt'> {
|
||||
const newUser = new User();
|
||||
newUser.username = username;
|
||||
newUser.displayName = displayName;
|
||||
newUser.photo = null;
|
||||
newUser.email = null;
|
||||
newUser.ownedNotes = [];
|
||||
newUser.authTokens = [];
|
||||
newUser.identities = Promise.resolve([]);
|
||||
newUser.groups = [];
|
||||
newUser.historyEntries = [];
|
||||
newUser.mediaUploads = [];
|
||||
newUser.authors = [];
|
||||
return newUser;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue