mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 17:55:17 -04:00
Entities: Add onDelete CASCADE to entities
To better handle deletion of entities, all necessary other entities got the option onDelete CASCADE set. So everything that does not make any sense if something else is deleted will be deleted along side of it. Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
5758463b07
commit
24ee95282d
6 changed files with 22 additions and 6 deletions
|
@ -21,6 +21,7 @@ import { User } from '../users/user.entity';
|
|||
import { AuthorColor } from './author-color.entity';
|
||||
import { Tag } from './tag.entity';
|
||||
import { HistoryEntry } from '../history/history-entry.entity';
|
||||
import { MediaUpload } from '../media/media-upload.entity';
|
||||
|
||||
@Entity()
|
||||
export class Note {
|
||||
|
@ -53,7 +54,9 @@ export class Note {
|
|||
default: 0,
|
||||
})
|
||||
viewCount: number;
|
||||
@ManyToOne((_) => User, (user) => user.ownedNotes, { onDelete: 'CASCADE' })
|
||||
@ManyToOne((_) => User, (user) => user.ownedNotes, {
|
||||
onDelete: 'CASCADE', // This deletes the Note, when the associated User is deleted
|
||||
})
|
||||
owner: User;
|
||||
@OneToMany((_) => Revision, (revision) => revision.note, { cascade: true })
|
||||
revisions: Promise<Revision[]>;
|
||||
|
@ -61,6 +64,8 @@ export class Note {
|
|||
authorColors: AuthorColor[];
|
||||
@OneToMany((_) => HistoryEntry, (historyEntry) => historyEntry.user)
|
||||
historyEntries: HistoryEntry[];
|
||||
@OneToMany((_) => MediaUpload, (mediaUpload) => mediaUpload.note)
|
||||
mediaUploads: MediaUpload[];
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue