From ba9d7a6572effbf691665f35ddf02a38c6549726 Mon Sep 17 00:00:00 2001 From: David Mehren <git@herrmehren.de> Date: Thu, 13 Aug 2020 20:22:30 +0200 Subject: [PATCH] Add AuthorColor entity Signed-off-by: David Mehren <git@herrmehren.de> --- src/notes/author-color.entity.ts | 23 +++++++++++++++++++++++ src/notes/notes.module.ts | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/notes/author-color.entity.ts diff --git a/src/notes/author-color.entity.ts b/src/notes/author-color.entity.ts new file mode 100644 index 000000000..3978822ea --- /dev/null +++ b/src/notes/author-color.entity.ts @@ -0,0 +1,23 @@ +import { Column, Entity, ManyToOne } from 'typeorm/index'; +import { User } from '../users/user.entity'; +import { Note } from './note.entity'; + +@Entity() +export class AuthorColor { + @ManyToOne( + _ => Note, + note => note.authorColors, + { + primary: true, + }, + ) + note: Note; + + @ManyToOne(_ => User, { + primary: true, + }) + user: User; + + @Column() + color: string; +} diff --git a/src/notes/notes.module.ts b/src/notes/notes.module.ts index d869d692a..1054935d3 100644 --- a/src/notes/notes.module.ts +++ b/src/notes/notes.module.ts @@ -1,10 +1,11 @@ import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; +import { AuthorColor } from './author-color.entity'; import { Note } from './note.entity'; import { NotesService } from './notes.service'; @Module({ - imports: [TypeOrmModule.forFeature([Note])], + imports: [TypeOrmModule.forFeature([Note, AuthorColor])], controllers: [], providers: [NotesService], exports: [NotesService],