From 8040f47d008c74f148927547ff147d5aa8083ac8 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Mon, 31 May 2021 18:39:33 +0200 Subject: [PATCH] Add Author property to Session & User The DB schema was updated in 0d6c3002, this adds the new author property to the Session and User entities. Signed-off-by: David Mehren --- src/users/session.entity.ts | 6 +++++- src/users/user.entity.ts | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/users/session.entity.ts b/src/users/session.entity.ts index 9603373e8..9b437296b 100644 --- a/src/users/session.entity.ts +++ b/src/users/session.entity.ts @@ -5,7 +5,8 @@ */ import { ISession } from 'connect-typeorm'; -import { Column, Entity, Index, PrimaryColumn } from 'typeorm'; +import { Column, Entity, Index, ManyToOne, PrimaryColumn } from 'typeorm'; +import { Author } from '../authors/author.entity'; @Entity() export class Session implements ISession { @@ -18,4 +19,7 @@ export class Session implements ISession { @Column('text') public json = ''; + + @ManyToOne(() => Author, (author) => author.sessions) + author: Author; } diff --git a/src/users/user.entity.ts b/src/users/user.entity.ts index b3267db57..d1843db03 100644 --- a/src/users/user.entity.ts +++ b/src/users/user.entity.ts @@ -12,6 +12,7 @@ import { UpdateDateColumn, } from 'typeorm'; import { Column, OneToMany } from 'typeorm'; +import { Author } from '../authors/author.entity'; import { Note } from '../notes/note.entity'; import { AuthToken } from '../auth/auth-token.entity'; import { Identity } from './identity.entity'; @@ -68,6 +69,9 @@ export class User { @OneToMany((_) => MediaUpload, (mediaUpload) => mediaUpload.user) mediaUploads: MediaUpload[]; + @OneToMany(() => Author, (author) => author.user) + authors: Author[]; + // eslint-disable-next-line @typescript-eslint/no-empty-function private constructor() {}