From 86a737951951c911abd7967d76cb253c4335cb0c Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Fri, 10 Feb 2023 11:15:23 +0100 Subject: [PATCH] fix: delete all shares of reverse share --- backend/src/reverseShare/reverseShare.service.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/reverseShare/reverseShare.service.ts b/backend/src/reverseShare/reverseShare.service.ts index 454e9913..76d3ba39 100644 --- a/backend/src/reverseShare/reverseShare.service.ts +++ b/backend/src/reverseShare/reverseShare.service.ts @@ -81,15 +81,15 @@ export class ReverseShareService { } async remove(id: string) { - const share = await this.prisma.share.findFirst({ + const shares = await this.prisma.share.findMany({ where: { reverseShare: { id } }, }); - if (share) { + for (const share of shares) { await this.prisma.share.delete({ where: { id: share.id } }); await this.fileService.deleteAllFiles(share.id); - } else { - await this.prisma.reverseShare.delete({ where: { id } }); } + + await this.prisma.reverseShare.delete({ where: { id } }); } }