fix(api): enhance logic

This commit is contained in:
yassinedorbozgithub
2025-06-12 17:41:20 +01:00
parent 3fe1cc4f28
commit 99f0f0eb2f
7 changed files with 48 additions and 66 deletions

View File

@@ -52,14 +52,15 @@ export class ContentTypeRepository extends BaseRepository<
>,
criteria: TFilterQuery<ContentType>,
) {
const entityId: string = criteria._id as string;
const associatedBlocks = await this.blockService?.findOne({
'options.content.entity': entityId,
});
if (associatedBlocks) {
throw new ForbiddenException(`Content type have blocks associated to it`);
}
if (criteria._id) {
const associatedBlock = await this.blockService?.findOne({
'options.content.entity': criteria._id,
});
if (associatedBlock) {
throw new ForbiddenException(
'Content type have blocks associated to it',
);
}
await this.contentModel.deleteMany({ entity: criteria._id });
} else {
throw new Error(