优化方法的使用
This commit is contained in:
Regular → Executable
+6
@@ -1,8 +1,14 @@
|
||||
// Package gormx 提供 responsex 的 GORM 分页辅助。
|
||||
//
|
||||
// 按需加载:只有显式 import 本包的项目才依赖 gorm。
|
||||
//
|
||||
// import 路径:code.yun.ink/pkg/responsex/gormx
|
||||
package gormx
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
// 计算GORM DB的分页
|
||||
// page 与 size 同时小于等于 0 时,只限制最大条数(1000),不做偏移
|
||||
func GetDbOffset(db *gorm.DB, page, size int64) *gorm.DB {
|
||||
offset := int(0)
|
||||
limit := int(0)
|
||||
|
||||
Reference in New Issue
Block a user