🐛 Add limitation of pagination
This commit is contained in:
parent
5ec6cacb69
commit
c5ed5e8df6
@ -79,6 +79,10 @@ WHERE t.id = ?`, prefix, prefix, prefix), post.ID).Scan(&reactInfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ListPost(tx *gorm.DB, take int, offset int) ([]*models.Post, error) {
|
func ListPost(tx *gorm.DB, take int, offset int) ([]*models.Post, error) {
|
||||||
|
if take > 20 {
|
||||||
|
take = 20
|
||||||
|
}
|
||||||
|
|
||||||
var posts []*models.Post
|
var posts []*models.Post
|
||||||
if err := PreloadRelatedPost(tx).
|
if err := PreloadRelatedPost(tx).
|
||||||
Limit(take).
|
Limit(take).
|
||||||
|
Loading…
Reference in New Issue
Block a user