Golang+gorm pagination, returning 50 pieces of data per page, is this correct?

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?

Oct.29,2021

there's no problem, that's how it's written. Gorm's db is also similar to chained operations.


won't you report a "no rows in result set" error if you send a value greater than 1 to offset?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b388cb-2c129.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b388cb-2c129.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?