В этом случае рекомендуется обработать его вручную, создать класс сущности CrossGroupDocumentPermissionEntity и добавить ManyToOne для каждого отношения, а с другой стороны в Документ, Группу, Пользователь добавить отношение OneToMany здесь - этопример использования в ManyToMany с настраиваемыми полями
Редактировать:
Пользователь
@Entity('User')
export class UserEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
@ManyToMany((type: any) => GroupEntity, (group: GroupEntity) => group.users)
@JoinTable()
groups: GroupEntity[];
@OneToMany((type: any) => CrossUserDocumentPermissionEntity, (documentPermission: CrossUserDocumentPermissionEntity) => documentPermission.user)
documentPermissions: CrossUserDocumentPermissionEntity[];
}
Группа
@Entity('Group')
export class GroupEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
@ManyToMany((type: any) => UserEntity, (user: UserEntity) => user.groups)
users: UserEntity[];
@OneToMany((type: any) => CrossGroupDocumentPermissionEntity, (documentPermission: CrossGroupDocumentPermissionEntity) => documentPermission.group)
documentPermissions: CrossGroupDocumentPermissionEntity[];
}
Разрешение
@Entity('Permission')
export class PermissionEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
@OneToMany((type: any) => CrossUserDocumentPermissionEntity, (userDocument: CrossUserDocumentPermissionEntity) => userDocument.permission)
usersDocuments: CrossUserDocumentPermissionEntity[];
@OneToMany((type: any) => CrossGroupDocumentPermissionEntity, (groupDocument: CrossUserDocumentPermissionEntity) => groupDocument.permission)
GroupDocuments: CrossGroupDocumentPermissionEntity[];
}
Документ
@Entity('Document')
export class DocumentEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
@OneToMany((type: any) => CrossUserDocumentPermissionEntity, (userPermission: CrossUserDocumentPermissionEntity) => userPermission.document)
usersPermissions: CrossUserDocumentPermissionEntity[];
@OneToMany((type: any) => CrossGroupDocumentPermissionEntity, (groupPermission: CrossUserDocumentPermissionEntity) => groupPermission.document)
GroupPermissions: CrossGroupDocumentPermissionEntity[];
}
Cross_User_Document_Permission
@Entity('Cross_User_Document_Permission')
export class CrossUserDocumentPermissionEntity {
@PrimaryColumn()
userId: string;
@PrimaryColumn()
permissionId: string;
@PrimaryColumn()
documentId: string;
@ManyToOne((type: any) => UserEntity, (user: UserEntity) => user.documentPermission)
user: UserEntity;
@ManyToOne((type: any) => DocumentEntity, (document: DocumentEntity) => document.userPermission)
document: DocumentEntity;
@ManyToOne((type: any) => PermissionEntity, (permission: PermissionEntity) => permission.userDocument)
permission: PermissionEntity;
}