more options for where clause

main v1.0.20
alex 2023-11-26 09:51:19 +01:00
parent 39ef3fa9e5
commit c4d37d1da8
1 changed files with 5 additions and 1 deletions

View File

@ -14,7 +14,11 @@ func GetTotalPages(database *gorm.DB, paginationLimit int, any interface{}, wher
if whereQuery == nil {
database.Model(any).
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).
Where(whereQuery, args).
Count(&totalPages)