1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

feat(wip): leaderboard pagination (resolve #417) [ci-skip]

This commit is contained in:
Ferdinand Mütsch
2022-10-16 18:59:19 +02:00
parent 8a21be4306
commit 41f6db8f34
9 changed files with 85 additions and 18 deletions

View File

@@ -39,3 +39,13 @@ func WhereNullable(query *gorm.DB, col string, val any) *gorm.DB {
}
return query.Where(fmt.Sprintf("%s = ?", col), val)
}
func WithPaging(query *gorm.DB, limit, skip int) *gorm.DB {
if limit >= 0 {
query = query.Limit(limit)
}
if skip >= 0 {
query = query.Offset(skip)
}
return query
}