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 4e14053f8f
commit 1dc6db24a9
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)
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;
}
}