List post with minimal data

This commit is contained in:
2024-08-10 21:11:55 +08:00
parent 8aa627ef43
commit 2fbf7c4808
3 changed files with 70 additions and 0 deletions

View File

@ -220,6 +220,22 @@ func ListPost(tx *gorm.DB, take int, offset int, order any, noReact ...bool) ([]
return items, nil
}
func ListPostMinimal(tx *gorm.DB, take int, offset int, order any) ([]*models.Post, error) {
if take > 500 {
take = 500
}
var items []*models.Post
if err := tx.
Limit(take).Offset(offset).
Order(order).
Find(&items).Error; err != nil {
return items, err
}
return items, nil
}
func EnsurePostCategoriesAndTags(item models.Post) (models.Post, error) {
var err error
for idx, category := range item.Categories {