where clause

main v1.0.21
alex 2023-11-26 09:58:59 +01:00
parent c4d37d1da8
commit 8cfb5d7869
1 changed files with 9 additions and 0 deletions

View File

@ -47,6 +47,15 @@ func DbPageQuery(database *gorm.DB, query PageQuery, paginationLimit int, result
Find(result)
}
if len(args) == 0 { // here used with db.Where(&User{Name: "jinzhu", Age: 20}).First(&user)
return database.Limit(paginationLimit).
Offset(GetPageOffset(query.Page, paginationLimit)).
Where(whereQuery).
Order(orderBy).
Find(result)
}
// here used with "name = ?", "jinzhu"
return database.Limit(paginationLimit).
Offset(GetPageOffset(query.Page, paginationLimit)).
Where(whereQuery, args).