Skip to content

Commit

Permalink
chore(libs): add paginated query options (#1365)
Browse files Browse the repository at this point in the history
Co-authored-by: David Ragot <david@formance.com>
  • Loading branch information
Dav-14 and David Ragot committed Mar 28, 2024
1 parent 7add8ae commit f38709c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions libs/go-libs/bun/bunpaginate/pagination_query_options.go
@@ -0,0 +1,30 @@
package bunpaginate

import (
"github.com/formancehq/stack/libs/go-libs/query"
)

type PaginatedQueryOptions[T any] struct {
QueryBuilder query.Builder `json:"qb"`
PageSize uint64 `json:"pageSize"`
Options T `json:"options"`
}

func (opts PaginatedQueryOptions[T]) WithQueryBuilder(qb query.Builder) PaginatedQueryOptions[T] {
opts.QueryBuilder = qb

return opts
}

func (opts PaginatedQueryOptions[T]) WithPageSize(pageSize uint64) PaginatedQueryOptions[T] {
opts.PageSize = pageSize

return opts
}

func NewPaginatedQueryOptions[T any](options T) PaginatedQueryOptions[T] {
return PaginatedQueryOptions[T]{
Options: options,
PageSize: QueryDefaultPageSize,
}
}

0 comments on commit f38709c

Please sign in to comment.