parent
39ef3fa9e5
commit
c4d37d1da8
|
@ -14,7 +14,11 @@ func GetTotalPages(database *gorm.DB, paginationLimit int, any interface{}, wher
|
||||||
if whereQuery == nil {
|
if whereQuery == nil {
|
||||||
database.Model(any).
|
database.Model(any).
|
||||||
Count(&totalPages)
|
Count(&totalPages)
|
||||||
} else {
|
} else if len(args) == 0 { // here used with db.Where(&User{Name: "jinzhu", Age: 20}).First(&user)
|
||||||
|
database.Model(any).
|
||||||
|
Where(whereQuery).
|
||||||
|
Count(&totalPages)
|
||||||
|
} else { // here used with "name = ?", "jinzhu"
|
||||||
database.Model(any).
|
database.Model(any).
|
||||||
Where(whereQuery, args).
|
Where(whereQuery, args).
|
||||||
Count(&totalPages)
|
Count(&totalPages)
|
||||||
|
|
Loading…
Reference in New Issue