Documentation ¶
Overview ¶
Package pagination provides functionalities related to cursor-based pagination.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface { Query(ctx context.Context, sql string, optionsAndArgs ...any) (pgx.Rows, error) QueryRow(ctx context.Context, sql string, optionsAndArgs ...any) pgx.Row }
Connection is used to represent a DB connection
type CursorFunc ¶
type CursorFunc func(cp CursorPaginatable) (*string, error)
CursorFunc creates an opaque cursor string
type CursorPaginatable ¶
CursorPaginatable implements functions needed to resolve fields for cursor pagination
type FieldDescriptor ¶
FieldDescriptor defines a field descriptor
type MockConnection ¶
MockConnection is an autogenerated mock type for the Connection type
func NewMockConnection ¶
func NewMockConnection(t mockConstructorTestingTNewMockConnection) *MockConnection
NewMockConnection creates a new instance of MockConnection. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
type PageInfo ¶
type PageInfo struct { Cursor CursorFunc TotalCount int32 HasNextPage bool HasPreviousPage bool }
PageInfo contains the page information
type PaginatedQueryBuilder ¶
type PaginatedQueryBuilder struct {
// contains filtered or unexported fields
}
PaginatedQueryBuilder represents a paginated DB query
func NewPaginatedQueryBuilder ¶
func NewPaginatedQueryBuilder( options *Options, primaryKey *FieldDescriptor, sortBy *FieldDescriptor, sortDirection SortDirection, ) (*PaginatedQueryBuilder, error)
NewPaginatedQueryBuilder returns a PaginatedQueryBuilder
func (*PaginatedQueryBuilder) Execute ¶
func (p *PaginatedQueryBuilder) Execute(ctx context.Context, conn Connection, query *goqu.SelectDataset) (PaginatedRows, error)
Execute executes the paginated query using the DB Connection
type PaginatedRows ¶
PaginatedRows contains the paginated query results
type SortDirection ¶
type SortDirection string
SortDirection indicates the direction for sorting results
const ( AscSort SortDirection = "ASC" DescSort SortDirection = "DESC" )
SortDirection constants