Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for Change: query.Offset = p.Page * p.Size to query.Offset = (p.Page - 1) * p.Size #14

Open
thisismz opened this issue Nov 2, 2023 · 1 comment

Comments

@thisismz
Copy link

thisismz commented Nov 2, 2023

Hello dear friend,

According to the GORM documentation, the offset should be configured as follows:
https://gorm.io/docs/scopes.html#Pagination

offset := (page - 1) * pageSize

However, in your code, you have set it to:
https://github.com/morkid/paginate/blob/6a80ba937ff9c76f988630fe32526430da23a071/paginate.go#L334C2-L334C32

If the total number of records is 6, but our limit is 10, meaning the total number of records in the database is less than our limit, we encounter a problem in the response.

I would appreciate it if you could check this issue. Thank you for the excellent package you've developed; it's been very helpful.

@thisismz
Copy link
Author

thisismz commented Nov 2, 2023

Additionally, I suggest removing or comment the following line from your code:

fmt.Println("paginate.Response(stmt, req, res) is deprecated! please use paginate.With(stmt).Request(req).Response(res) instead")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant