From 88736fb97983e9ccec5872efbb32cadaa5c2bd2e Mon Sep 17 00:00:00 2001 From: Danka Marcell Date: Wed, 27 Nov 2024 22:38:19 +0100 Subject: [PATCH] fix --- apps/backend/src/band/band.service.ts | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/apps/backend/src/band/band.service.ts b/apps/backend/src/band/band.service.ts index 1d2d2c2..1dc0236 100644 --- a/apps/backend/src/band/band.service.ts +++ b/apps/backend/src/band/band.service.ts @@ -69,15 +69,9 @@ export class BandService { } async addMember(bandId: number, userId: number): Promise { - if (await this.prisma.bandMembership.findUnique({ where: { bandId: { bandId }, userId: { userId } } })) { - throw new NotFoundException('User is already a member of the band'); - } - if (!(await this.prisma.user.findUnique({ where: { id: userId } }))) { - throw new NotFoundException('User does not exist'); - } try { const res = await this.prisma.bandMembership.create({ - BandMembership: { band: { connect: { id: bandId } }, user: { connect: { id: userId } } }, + data: { band: { connect: { id: bandId } }, user: { connect: { id: userId } } }, }); if (!res) throw new Error(); return res; @@ -87,9 +81,6 @@ export class BandService { } async removeMember(bandId: number, userId: number): Promise { - if (!(await this.prisma.bandMembership.findUnique({ where: { bandId: { bandId }, userId: { userId } } }))) { - throw new NotFoundException('User is not a member of the band'); - } try { const res = await this.prisma.bandMembership.delete({ where: { bandId, userId } }); if (!res) throw new Error();