Skip to content

Commit d930158

Browse files
committed
fix: filter posts to exclude replies in pagination query
1 parent d73b76c commit d930158

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

repository/post_repository.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (r *postRepository) GetAllPostsWithPagination(ctx context.Context, tx *gorm
100100

101101
req.Default()
102102

103-
query := tx.WithContext(ctx).Model(&entity.Post{}).Joins("User")
103+
query := tx.WithContext(ctx).Model(&entity.Post{}).Joins("User").Where("posts.parent_id IS NULL").Order("created_at DESC")
104104
if req.Search != "" {
105105
query = query.Where("text LIKE ?", "%"+req.Search+"%")
106106
}

0 commit comments

Comments
 (0)