Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type Cursor
- type CustomType
- type MetaType
- type Option
- type Order
- type Page
- type Paginator
- func (p *Paginator) Paginate(ctx context.Context, db SQLSelector, ds *goqu.SelectDataset, dest any) (*Cursor, error)
- func (p *Paginator) SetAfterCursor(afterCursor string)
- func (p *Paginator) SetBeforeCursor(beforeCursor string)
- func (p *Paginator) SetKeys(keys ...string)
- func (p *Paginator) SetLimit(limit int)
- func (p *Paginator) SetOrder(order Order)
- func (p *Paginator) SetPage(page int)
- func (p *Paginator) SetRules(rules ...Rule)
- type Rule
- type SQLSelector
Constants ¶
View Source
const DefaultPaginatorLimit = 100
Variables ¶
View Source
var ( ErrInvalidCursor = errors.New("invalid cursor for paginating") ErrInvalidLimit = errors.New("limit should be greater than 0") ErrInvalidModel = errors.New("entity fields should match rules or keys specified for paginator") ErrInvalidOrder = errors.New("order should be ASC or DESC") ErrNoRule = errors.New("paginator should have at least one rule") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Rules []Rule Keys []string Limit int Order Order After string Before string Page int }
Config for paginator
type CustomType ¶
CustomType for paginator. It provides extra info needed to paginate across custom types (e.g. JSON)
type Option ¶
type Option interface {
Apply(p *Paginator)
}
Option for paginator
func WithBefore ¶
WithBefore configures before cursor for paginator
type Paginator ¶
type Paginator struct {
// contains filtered or unexported fields
}
Paginator a builder doing pagination
func (*Paginator) SetAfterCursor ¶
SetAfterCursor sets paging after cursor
func (*Paginator) SetBeforeCursor ¶
SetBeforeCursor sets paging before cursor
Source Files ¶
Click to show internal directories.
Click to hide internal directories.