chore: add is pinned to the blog entity and also add route for it

This commit is contained in:
mahyargdz
2025-04-12 16:28:02 +03:30
parent 39cce1c380
commit d76b9326e6
6 changed files with 53 additions and 2 deletions
@@ -191,4 +191,25 @@ export class BlogsRepository extends Repository<Blog> {
.take(limit)
.getMany();
}
async getPinnedBlogs(limit: number = 4) {
return this.createQueryBuilder("blog")
.where("blog.deletedAt IS NULL")
.andWhere("blog.isActive = :isActive", { isActive: true })
.andWhere("blog.isPinned = :isPinned", { isPinned: true })
.select([
"blog.id",
"blog.title",
"blog.previewContent",
"blog.metaTitle",
"blog.metaDescription",
"blog.imageUrl",
"blog.slug",
"blog.createdAt",
"blog.viewCount",
])
.orderBy("blog.createdAt", "DESC")
.take(limit)
.getMany();
}
}