fix: the blog entitiy cascade option
This commit is contained in:
@@ -49,7 +49,7 @@ export class Blog extends BaseEntity {
|
||||
@Index()
|
||||
author: User;
|
||||
|
||||
@ManyToOne(() => BlogCategory, (category) => category.blogs, { nullable: false })
|
||||
@ManyToOne(() => BlogCategory, (category) => category.blogs, { nullable: false, onDelete: "CASCADE" })
|
||||
@Index()
|
||||
category: BlogCategory;
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ export class BlogsService {
|
||||
const category = await this.blogCategoriesRepository.findOneBy({ id });
|
||||
if (!category) throw new BadRequestException(BlogMessage.CATEGORY_NOT_FOUND);
|
||||
|
||||
await this.blogCategoriesRepository.softDelete({ id });
|
||||
await this.blogCategoriesRepository.delete({ id });
|
||||
return {
|
||||
message: CommonMessage.DELETED,
|
||||
};
|
||||
|
||||
@@ -41,6 +41,7 @@ export class BlogCommentsRepository extends Repository<BlogComment> {
|
||||
const { limit, skip } = PaginationUtils(queryDto);
|
||||
const query = this.createQueryBuilder("blogComment")
|
||||
.leftJoin("blogComment.blog", "blog")
|
||||
.where("blog.deletedAt IS NULL")
|
||||
.addSelect(["blog.id", "blog.title"])
|
||||
.leftJoin("blogComment.user", "user")
|
||||
.addSelect(["user.id", "user.firstName", "user.lastName"]);
|
||||
|
||||
Reference in New Issue
Block a user