chore: add is pinned to the blog entity and also add route for it
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user