From 48a4de7234a62c0d1e23b3647ddfd356f08d4180 Mon Sep 17 00:00:00 2001 From: ElegantSoft Date: Wed, 2 Nov 2022 14:02:47 +0200 Subject: [PATCH] fix issue in count --- crud/service.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crud/service.go b/crud/service.go index c6ba634..299928b 100644 --- a/crud/service.go +++ b/crud/service.go @@ -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 }