the frontend is pulled down and refreshed, and the backend returns 50 pieces of data at a time. I wonder if the api, written by go+gorm is correct? Please have a look at
gorm: http://gorm.io/zh_CN/docs/que.
func ListArticle(offset int) ([]*ArticleModel, uint64, error) {
articles := make([]*ArticleModel, 0)
var count uint64
if err := DB.Self.Where("status = ?", "1").Offset(offset).Limit(50).Order("id desc").Find(&articles).Count(&count).Error; err != nil {
return articles, count, err
}
return articles, count, nil
}
use offset+limit to implement this function, right? Is there anything that needs to be optimized?