Skip to content

Commit bdb585c

Browse files
committed
fix: update paginator option functions for clarity and consistency
1 parent 515735a commit bdb585c

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

page.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,24 +179,28 @@ type PaginatorSettings struct {
179179

180180
type PaginatorOption func(*PaginatorSettings)
181181

182+
// WithDefaultSize sets the default page size.
182183
func WithDefaultSize(size uint32) PaginatorOption {
183184
return func(s *PaginatorSettings) {
184185
s.DefaultSize = size
185186
}
186187
}
187188

189+
// WithMaxSize sets the maximum page size.
188190
func WithMaxSize(size uint32) PaginatorOption {
189191
return func(s *PaginatorSettings) {
190192
s.MaxSize = size
191193
}
192194
}
193195

194-
func WithDefaultSort(sort ...string) PaginatorOption {
196+
// WithSort sets the default sort order.
197+
func WithSort(sort ...string) PaginatorOption {
195198
return func(s *PaginatorSettings) {
196199
s.Sort = sort
197200
}
198201
}
199202

203+
// WithColumnFunc sets a function to transform column names.
200204
func WithColumnFunc(f func(string) string) PaginatorOption {
201205
return func(s *PaginatorSettings) {
202206
s.ColumnFunc = f

page_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func TestPagination(t *testing.T) {
1717
pgkit.WithColumnFunc(strings.ToLower),
1818
pgkit.WithDefaultSize(2),
1919
pgkit.WithMaxSize(_MaxSize),
20-
pgkit.WithDefaultSort("ID"),
20+
pgkit.WithSort("ID"),
2121
}
2222
paginator := pgkit.NewPaginator[T](options...)
2323
page := pgkit.NewPage(0, 0)

0 commit comments

Comments
 (0)