Documentation ¶
Index ¶
Constants ¶
const ( // DefaultPage defines the default page number DefaultPage = 1 // DefaultPageSize defines the default number of items per page // TODO: change to 15 when all clients are updated DefaultPageSize = 50 )
const DefaultCursorLimit = 10
DefaultCursorLimit is the default number of items per page for cursor-based pagination
Variables ¶
This section is empty.
Functions ¶
func EncodeCursor ¶ added in v0.135.0
EncodeCursor generates a base64 encoded representation of a timestamp + identifier
func IsCursorPaginationError ¶ added in v0.135.0
IsCursorPaginationError checks if the error is an CursorPaginationError
func IsOffsetPaginationError ¶
IsOffsetPaginationError checks if the error is an OffsetPaginationError
Types ¶
type Cursor ¶ added in v0.135.0
Cursor is a struct that holds the timestamp and identifier of a record
type CursorOptions ¶ added in v0.135.0
CursorOptions is a struct that holds the cursor and limit for pagination
type CursorPaginationError ¶ added in v0.135.0
type CursorPaginationError struct {
// contains filtered or unexported fields
}
CursorPaginationError is the error type for cursor-based pagination
func NewCursorPaginationError ¶ added in v0.135.0
func NewCursorPaginationError(err error) CursorPaginationError
NewCursorPaginationError creates a new CursorPaginationError with the provided error
func (CursorPaginationError) Error ¶ added in v0.135.0
func (e CursorPaginationError) Error() string
Error returns the error message
type OffsetPaginationError ¶
type OffsetPaginationError struct {
// contains filtered or unexported fields
}
OffsetPaginationError is the error type for page-based pagination
func NewOffsetPaginationErrorStr ¶
func NewOffsetPaginationErrorStr(errMsg string) OffsetPaginationError
NewOffsetPaginationErrorStr creates a new OffsetPaginationError with the provided error message
func (OffsetPaginationError) Error ¶
func (e OffsetPaginationError) Error() string
Error returns the error message
func (OffsetPaginationError) Unwrap ¶
func (e OffsetPaginationError) Unwrap() error
Unwrap returns the wrapped error
type OffsetPaginationOpts ¶
type OffsetPaginationOpts struct {
// contains filtered or unexported fields
}
OffsetPaginationOpts is the options for page-based pagination
func NewDefaultOffsetPaginationOpts ¶
func NewDefaultOffsetPaginationOpts() *OffsetPaginationOpts
NewDefaultOffsetPaginationOpts creates a new OffsetPaginationOpts with default values
func NewOffsetPaginationOpts ¶
func NewOffsetPaginationOpts(offset, limit int) (*OffsetPaginationOpts, error)
NewOffsetPaginationOpts creates a new OffsetPaginationOpts with the provided page and pageSize
func (*OffsetPaginationOpts) Limit ¶
func (o *OffsetPaginationOpts) Limit() int
Limit returns the number of items per page
func (*OffsetPaginationOpts) Offset ¶
func (o *OffsetPaginationOpts) Offset() int
Offset returns the page number