mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-03 00:19:57 -04:00
History: Add HistoryEntry
With this the backend now can hold a history entry. Also included in this commit are some minor changes to tests and services so they can still work. Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
6bce4c241b
commit
b76fa91a3c
7 changed files with 72 additions and 2 deletions
47
src/history/history-entry.entity.ts
Normal file
47
src/history/history-entry.entity.ts
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import {
|
||||
Column,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
import { User } from '../users/user.entity';
|
||||
import { Note } from '../notes/note.entity';
|
||||
|
||||
@Entity()
|
||||
export class HistoryEntry {
|
||||
@ManyToOne((_) => User, (user) => user.historyEntries, {
|
||||
onDelete: 'CASCADE',
|
||||
primary: true,
|
||||
})
|
||||
user: User;
|
||||
|
||||
@ManyToOne((_) => Note, (note) => note.historyEntries, {
|
||||
onDelete: 'CASCADE',
|
||||
primary: true,
|
||||
})
|
||||
note: Note;
|
||||
|
||||
@Column()
|
||||
pinStatus: boolean;
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedAt: Date;
|
||||
|
||||
// The optional note parameter is necessary for the createNote method in the NotesService,
|
||||
// as we create the note then and don't need to add it to the HistoryEntry.
|
||||
public static create(user: User, note?: Note): HistoryEntry {
|
||||
const newHistoryEntry = new HistoryEntry();
|
||||
newHistoryEntry.user = user;
|
||||
if (note) {
|
||||
newHistoryEntry.note = note;
|
||||
}
|
||||
newHistoryEntry.pinStatus = false;
|
||||
return newHistoryEntry;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue