chore: add blog blog comment and blog category crud
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { InjectRepository } from "@nestjs/typeorm";
|
||||
import { Repository } from "typeorm";
|
||||
|
||||
import { BlogComment } from "../entities/blog-comment.entity";
|
||||
import { CommentStatus } from "../enums/comment-status.enum";
|
||||
|
||||
@Injectable()
|
||||
export class BlogCommentsRepository extends Repository<BlogComment> {
|
||||
constructor(@InjectRepository(BlogComment) blogCommentsRepository: Repository<BlogComment>) {
|
||||
super(blogCommentsRepository.target, blogCommentsRepository.manager, blogCommentsRepository.queryRunner);
|
||||
}
|
||||
|
||||
async findOneById(id: string) {
|
||||
return this.findOne({
|
||||
where: { id },
|
||||
});
|
||||
}
|
||||
|
||||
async findAllByBlogId(blogId: string) {
|
||||
return this.find({
|
||||
where: { blog: { id: blogId }, status: CommentStatus.APPROVED },
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user