AuthorEntity: Add create method

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-05-19 22:12:00 +02:00
parent 228c2941e5
commit 62e442343a
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3

View file

@ -54,4 +54,18 @@ export class Author {
*/ */
@OneToMany(() => Authorship, (authorship) => authorship.author) @OneToMany(() => Authorship, (authorship) => authorship.author)
authorships: Authorship[]; authorships: Authorship[];
// eslint-disable-next-line @typescript-eslint/no-empty-function
private constructor() {}
public static create(
color: number,
): Pick<Author, 'color' | 'sessions' | 'user' | 'authorships'> {
const newAuthor = new Author();
newAuthor.color = color;
newAuthor.sessions = [];
newAuthor.user = null;
newAuthor.authorships = [];
return newAuthor;
}
} }