Files
homebox/backend/internal/data/repo/pagination.go
2025-06-09 15:23:56 -04:00

18 lines
312 B
Go

package repo
type PaginationResult[T any] struct {
Page int `json:"page"`
PageSize int `json:"pageSize"`
Total int `json:"total"`
Items []T `json:"items"`
}
func calculateOffset(page, pageSize int) int {
offset := (page - 1) * pageSize
if offset < 0 {
return 0
} else {
return offset
}
}