Skip to content

Commit

Permalink
fix issue in count
Browse files Browse the repository at this point in the history
  • Loading branch information
ElegantSoft committed Nov 2, 2022
1 parent 2455576 commit 48a4de7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crud/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ func (svc *Service[T]) FindTrx(api GetAllRequest) (error, *gorm.DB) {

tx.Limit(api.Limit)

if api.Page > 0 {
tx.Offset((api.Page - 1) * api.Limit)
}
return nil, tx
}

func (svc *Service[T]) Find(api GetAllRequest, result interface{}, totalRows *int64) error {
err, tx := svc.FindTrx(api)
tx.Count(totalRows)
if api.Page > 0 {
tx.Offset((api.Page - 1) * api.Limit)
}
if err != nil {
return err
}
Expand Down

0 comments on commit 48a4de7

Please sign in to comment.