Documentation
¶
Index ¶
- Variables
- type Config
- type Cursor
- type CustomType
- type Flag
- type Option
- type Order
- type Paginator
- func (p *Paginator) GetCursorDecoder() *cursor.Decoder
- func (p *Paginator) GetCursorEncoder() *cursor.Encoder
- func (p *Paginator) Paginate(db *gorm.DB, dest interface{}) (result *gorm.DB, c Cursor, err error)
- func (p *Paginator) SetAfterCursor(afterCursor string)
- func (p *Paginator) SetAllowTupleCmp(allow bool)
- 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) SetRules(rules ...Rule)
- type Rule
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidCursor = errors.New("invalid cursor for paginating") ErrInvalidLimit = errors.New("limit should be greater than 0") ErrInvalidModel = errors.New("model 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") )
Errors for paginator
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Rules []Rule Keys []string Limit int Order Order After string Before string AllowTupleCmp Flag }
Config for paginator
type CustomType ¶ added in v2.3.0
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 WithAllowTupleCmp ¶ added in v2.6.0
WithAllowTupleCmp enables tuple comparison optimization
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) GetCursorDecoder ¶ added in v2.5.0
GetCursorDecoder returns cursor decoder based on paginator rules
func (*Paginator) GetCursorEncoder ¶ added in v2.5.0
GetCursorEncoder returns cursor encoder based on paginator rules
func (*Paginator) SetAfterCursor ¶
SetAfterCursor sets paging after cursor
func (*Paginator) SetAllowTupleCmp ¶ added in v2.6.0
SetAllowTupleCmp enables or disables tuple comparison optimization
func (*Paginator) SetBeforeCursor ¶
SetBeforeCursor sets paging before cursor
Source Files
¶
Click to show internal directories.
Click to hide internal directories.