update: add blog comment to the blog fetch by id
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { InjectRepository } from "@nestjs/typeorm";
|
||||
import { Repository } from "typeorm";
|
||||
import { IsNull, Repository } from "typeorm";
|
||||
|
||||
import { BlogComment } from "../entities/blog-comment.entity";
|
||||
import { CommentStatus } from "../enums/comment-status.enum";
|
||||
@@ -17,10 +17,39 @@ export class BlogCommentsRepository extends Repository<BlogComment> {
|
||||
});
|
||||
}
|
||||
|
||||
async findAllByBlogId(blogId: string) {
|
||||
async findBlogCommentsForAdmin(blogId: string) {
|
||||
return this.find({
|
||||
where: { blog: { id: blogId }, status: CommentStatus.APPROVED },
|
||||
where: { blog: { id: blogId, deletedAt: IsNull() } },
|
||||
order: { createdAt: "DESC" },
|
||||
relations: {
|
||||
user: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
content: true,
|
||||
createdAt: true,
|
||||
status: true,
|
||||
user: { id: true, firstName: true, lastName: true },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async findBlogCommentsByBlogId(blogId: string) {
|
||||
return this.find({
|
||||
where: { blog: { id: blogId, deletedAt: IsNull() }, status: CommentStatus.APPROVED },
|
||||
order: { createdAt: "DESC" },
|
||||
relations: {
|
||||
user: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
content: true,
|
||||
createdAt: true,
|
||||
status: true,
|
||||
user: { id: true, firstName: true, lastName: true },
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user