models

package
v0.0.0-...-d389d3b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CriteriaAndPagination

type CriteriaAndPagination[T any] struct {
	Criteria   T
	Pagination Pagination
}

func NewCriteriaAndPagination

func NewCriteriaAndPagination[T any](criteria T) CriteriaAndPagination[T]

type Page

type Page[T any] struct {
	Content               []T
	Pageable              Pageable
	TotalNumberOfElements int
}

TODO next Pageable, map.

func NewEmptyPage

func NewEmptyPage[T any]() *Page[T]

func NewPage

func NewPage[T any](content []T, pageable Pageable, total int) *Page[T]

func NewPageWith

func NewPageWith[T any](content []T, pageable Pageable, totalSupplier TotalSupplier) (*Page[T], error)

func (Page[T]) IsEmpty

func (p Page[T]) IsEmpty() bool

func (Page[T]) NumberOfElements

func (p Page[T]) NumberOfElements() int

func (Page[T]) TotalPages

func (p Page[T]) TotalPages() int

type Pageable

type Pageable interface {
	PageNumber() int
	Offset() int
	PageSize() int
}

type Pagination

type Pagination struct {
	Page      int    `json:"page" uri:"page" form:"page"`
	Limit     int    `json:"limit" uri:"limit" form:"limit"`
	Field     string `json:"field" uri:"field" form:"field"`
	Direction string `json:"direction" uri:"direction" form:"direction"` // TODO, validation, default
}

func NewPaginationWithDefaults

func NewPaginationWithDefaults() Pagination

func (Pagination) IsOrderDefined

func (p Pagination) IsOrderDefined() bool

func (Pagination) Offset

func (p Pagination) Offset() int

func (Pagination) Order

func (p Pagination) Order() string

func (Pagination) PageNumber

func (p Pagination) PageNumber() int

func (Pagination) PageSize

func (p Pagination) PageSize() int

type TotalSupplier

type TotalSupplier func() (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL