mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-26 11:43:59 -05:00
5ed2fae44e
Signed-off-by: David Mehren <git@herrmehren.de>
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
import { Column, Entity, ManyToOne, UpdateDateColumn } from 'typeorm';
|
|
|
|
import { Note } from '../notes/note.entity';
|
|
import { User } from '../users/user.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;
|
|
}
|
|
}
|