Merge pull request #1039 from hedgedoc/fix/permissionsCreationAndFinding

This commit is contained in:
Yannick Bungers 2021-04-18 22:45:24 +02:00 committed by GitHub
commit eaa5254418
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 5 deletions

View file

@ -10,10 +10,16 @@ import { Note } from '../notes/note.entity';
@Entity()
export class NoteGroupPermission {
@ManyToOne((_) => Group, { primary: true })
@ManyToOne((_) => Group, {
primary: true,
onDelete: 'CASCADE', // This deletes the NoteGroupPermission, when the associated Group is deleted
})
group: Group;
@ManyToOne((_) => Note, (note) => note.groupPermissions, { primary: true })
@ManyToOne((_) => Note, (note) => note.groupPermissions, {
primary: true,
onDelete: 'CASCADE', // This deletes the NoteGroupPermission, when the associated Note is deleted
})
note: Note;
@Column()

View file

@ -10,10 +10,16 @@ import { User } from '../users/user.entity';
@Entity()
export class NoteUserPermission {
@ManyToOne((_) => User, { primary: true })
@ManyToOne((_) => User, {
primary: true,
onDelete: 'CASCADE', // This deletes the NoteUserPermission, when the associated Note is deleted
})
user: User;
@ManyToOne((_) => Note, (note) => note.userPermissions, { primary: true })
@ManyToOne((_) => Note, (note) => note.userPermissions, {
primary: true,
onDelete: 'CASCADE', // This deletes the NoteUserPermission, when the associated Note is deleted
})
note: Note;
@Column()