diff --git a/rspagination/rspagination.go b/rspagination/rspagination.go index d52e392..456c499 100644 --- a/rspagination/rspagination.go +++ b/rspagination/rspagination.go @@ -47,6 +47,15 @@ func DbPageQuery(database *gorm.DB, query PageQuery, paginationLimit int, result Find(result) } + if len(args) == 0 { // here used with db.Where(&User{Name: "jinzhu", Age: 20}).First(&user) + return database.Limit(paginationLimit). + Offset(GetPageOffset(query.Page, paginationLimit)). + Where(whereQuery). + Order(orderBy). + Find(result) + } + + // here used with "name = ?", "jinzhu" return database.Limit(paginationLimit). Offset(GetPageOffset(query.Page, paginationLimit)). Where(whereQuery, args).