Documentation
¶
Overview ¶
templ: version: v0.3.1020
Index ¶
- func GetPageNum(n any) int
- type PageObject
- type Pagination
- type Paginator
- type QueryPaginator
- func (p *QueryPaginator[T]) BaseURL() string
- func (p *QueryPaginator[T]) Count() (int, error)
- func (p *QueryPaginator[T]) GetQuerySet() *queries.QuerySet[T]
- func (p *QueryPaginator[T]) NumPages() (int, error)
- func (p *QueryPaginator[T]) Page(n int) (PageObject[T], error)
- func (p *QueryPaginator[T]) PerPage() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPageNum ¶
Types ¶
type PageObject ¶
type PageObject[T any] interface { // The number of objects on this page. // // This is NOT the total number of objects in the paginator. // // This might be less than the per page amount Count() int // A list of results on this page // Results() iter.Seq[S, E] Results() []T // The current page number PageNum() int // If the page has a next page HasNext() bool // If the page has a previous page HasPrev() bool // The next page number // This should return -1 if there is no next page Next() int // The previous page number // This should return -1 if there is no previous page Prev() int // A backreference to the paginator Paginator() Pagination[T] }
func NewPageObject ¶ added in v1.7.2
func NewPageObject[T any](ctx context.Context, paginator Pagination[T], num int, results []T) PageObject[T]
type Pagination ¶
type Paginator ¶
type Paginator[S ~[]E, E any] struct { Context context.Context GetObject func(E) E GetObjects func(amount int, offset int) (S, error) GetCount func() (int, error) Amount int URL string // contains filtered or unexported fields }
Paginator holds pagination logic
type QueryPaginator ¶ added in v1.7.2
type QueryPaginator[T attrs.Definer] struct { Context context.Context BaseQuerySet func() *queries.QuerySet[T] GetObject func(T) T URL string Amount int // contains filtered or unexported fields }
QueryPaginator holds pagination logic
func (*QueryPaginator[T]) BaseURL ¶ added in v1.7.2
func (p *QueryPaginator[T]) BaseURL() string
func (*QueryPaginator[T]) Count ¶ added in v1.7.2
func (p *QueryPaginator[T]) Count() (int, error)
func (*QueryPaginator[T]) GetQuerySet ¶ added in v1.7.2
func (p *QueryPaginator[T]) GetQuerySet() *queries.QuerySet[T]
func (*QueryPaginator[T]) NumPages ¶ added in v1.7.2
func (p *QueryPaginator[T]) NumPages() (int, error)
func (*QueryPaginator[T]) Page ¶ added in v1.7.2
func (p *QueryPaginator[T]) Page(n int) (PageObject[T], error)
func (*QueryPaginator[T]) PerPage ¶ added in v1.7.2
func (p *QueryPaginator[T]) PerPage() int
Click to show internal directories.
Click to hide internal directories.