listing

package
v0.34.2 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package listing holds shared pagination and sort value objects for list queries.

Index

Constants

View Source
const (
	DefaultPage = 1
	DefaultSize = 20
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction

type Direction string

Direction is the sort direction for a list query.

const (
	Asc  Direction = "asc"
	Desc Direction = "desc"
)

func (Direction) SQL

func (d Direction) SQL() string

SQL returns the SQL keyword for this direction. Empty defaults to DESC.

type Page

type Page struct {
	Number int
	Size   int
}

Page is a 1-based page request.

func (Page) Normalize

func (p Page) Normalize() Page

Normalize applies defaults for missing page/size values.

func (Page) Offset

func (p Page) Offset() int

Offset returns the SQL OFFSET for this page.

type Sort

type Sort struct {
	Field     string
	Direction Direction
}

Sort is an optional field + direction pair. A zero Sort means the repository default (typically created_at DESC). Field must be validated against a whitelist before it reaches SQL.

func (Sort) IsZero

func (s Sort) IsZero() bool

IsZero reports whether no sort was requested.

Jump to

Keyboard shortcuts

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