From 221fd47e2e71d87ca3532b6479f8ecf5cc396f48 Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Thu, 21 Nov 2024 16:11:53 +0400 Subject: [PATCH] fixed delete bug --- libs/common/src/modules/space/entities/space.entity.ts | 5 ++++- src/space/services/space.service.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/common/src/modules/space/entities/space.entity.ts b/libs/common/src/modules/space/entities/space.entity.ts index 38d4c5e..8aa717a 100644 --- a/libs/common/src/modules/space/entities/space.entity.ts +++ b/libs/common/src/modules/space/entities/space.entity.ts @@ -48,7 +48,10 @@ export class SpaceEntity extends AbstractEntity { @ManyToOne(() => SpaceEntity, (space) => space.children, { nullable: true }) parent: SpaceEntity; - @OneToMany(() => SpaceEntity, (space) => space.parent) + @OneToMany(() => SpaceEntity, (space) => space.parent, { + nullable: false, + onDelete: 'CASCADE', + }) children: SpaceEntity[]; @OneToMany(() => UserSpaceEntity, (userSpace) => userSpace.space) diff --git a/src/space/services/space.service.ts b/src/space/services/space.service.ts index 44d27ba..6e3e600 100644 --- a/src/space/services/space.service.ts +++ b/src/space/services/space.service.ts @@ -126,8 +126,8 @@ export class SpaceService { try { // First, check if the community exists const space = await this.validateCommunityAndSpace( - spaceUuid, communityUuid, + spaceUuid, ); // Delete the space