From 82f6e6920c4eacc86f84e2b78d8a248b23a1abd4 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Wed, 12 Aug 2020 20:52:26 +0200 Subject: [PATCH] Update revision entity according to the current database scheme. Signed-off-by: David Mehren --- src/revisions/revision.entity.ts | 44 ++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/src/revisions/revision.entity.ts b/src/revisions/revision.entity.ts index d3ed60afa..4427454e2 100644 --- a/src/revisions/revision.entity.ts +++ b/src/revisions/revision.entity.ts @@ -4,47 +4,65 @@ import { Entity, ManyToOne, PrimaryGeneratedColumn, - UpdateDateColumn, } from 'typeorm'; +import { JoinTable, ManyToMany } from 'typeorm/index'; import { Note } from '../notes/note.entity'; +import { Authorship } from './authorship.entity'; +/** + * The state of a note at a particular point in time, + * with the content at that time and the diff to the previous revision. + * + */ @Entity() export class Revision { - //TODO: This is the old schema, we probably want to change it @PrimaryGeneratedColumn('uuid') id: string; + /** + * The patch from the previous revision to this one. + */ @Column({ type: 'text', }) patch: string; - @Column({ - type: 'text', - }) - lastContent: string; - + /** + * The note content at this revision. + */ @Column({ type: 'text', }) content: string; + /** + * The length of the note content. + */ @Column() length: number; - @Column({ type: 'text' }) - authorship: string; - + /** + * Date at which the revision was created. + */ @CreateDateColumn() createdAt: Date; - @UpdateDateColumn() - updatedAt: Date; - + /** + * Note this revision belongs to. + */ @ManyToOne( _ => Note, note => note.revisions, { onDelete: 'CASCADE' }, ) note: Note; + /** + * All authorship objects which are used in the revision. + */ + @ManyToMany( + _ => Authorship, + authorship => authorship.revisions, + ) + @JoinTable() + authorships: Authorship[]; }