forked from yaitoo/sqle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlimit_option.go
More file actions
25 lines (21 loc) · 864 Bytes
/
Copy pathlimit_option.go
File metadata and controls
25 lines (21 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package sqle
// LimitOption is a function type that modifies a LimitedQuery.
type LimitOption func(q *LimitOptions)
// LimitOptions represents a query with pagination and ordering options.
type LimitOptions struct {
Offset int64 // Offset represents the number of rows to skip before returning the result set.
Limit int64 // Limit represents the maximum number of results to be returned.
OrderBy *OrderByBuilder // OrderBy represents the ordering of the query.
}
// WithPageSize is a LimitedQueryOption that sets the page size of the LimitedQuery.
func WithPageSize(size int64) LimitOption {
return func(q *LimitOptions) {
q.Limit = size
}
}
// WithOrderBy is a LimitedQueryOption that sets the ordering of the LimitedQuery.
func WithOrderBy(ob *OrderByBuilder) LimitOption {
return func(q *LimitOptions) {
q.OrderBy = ob
}
}