parent
6a6d2c7042
commit
56821c2833
|
@ -11,9 +11,14 @@ import (
|
|||
func GetTotalPages(database *gorm.DB, paginationLimit int, any interface{}, whereQuery interface{}, args ...interface{}) int {
|
||||
var totalPages int64
|
||||
|
||||
database.Model(any).
|
||||
Where(whereQuery, args).
|
||||
Count(&totalPages)
|
||||
if whereQuery == nil {
|
||||
database.Model(any).
|
||||
Count(&totalPages)
|
||||
} else {
|
||||
database.Model(any).
|
||||
Where(whereQuery, args).
|
||||
Count(&totalPages)
|
||||
}
|
||||
|
||||
return int(math.Ceil(float64(totalPages) / float64(paginationLimit)))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue