query.go 320 B

1234567891011121314151617181920212223
  1. package helpers
  2. type Query struct {
  3. PageSize int
  4. Page int
  5. }
  6. type QueryOption func(*Query)
  7. func WithPage(page int) func(q *Query) {
  8. if page == 0 {
  9. page = 1
  10. }
  11. return func(q *Query) {
  12. q.Page = page
  13. }
  14. }
  15. func WithPageSize(pageSize int) func(q *Query) {
  16. return func(q *Query) {
  17. q.PageSize = pageSize
  18. }
  19. }