sort

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction

type Direction = string

Direction defines the sorting direction as a string type.

const (
	Ascending  Direction = "asc"
	Descending Direction = "desc"
)

func DirectionFromString

func DirectionFromString(dir string) Direction

DirectionFromString converts a string to a Direction, defaulting to Ascending.

type Order

type Order struct {
	// contains filtered or unexported fields
}

Order represents sorting criteria with a column and direction.

func Default

func Default() Order

Default returns a default Order by "id" in ascending order.

func NewOrder

func NewOrder(by string, direction Direction) Order

NewOrder creates a new Order with the given column and direction.

func (Order) By

func (o Order) By() string

By returns the column name used for ordering.

func (Order) Direction

func (o Order) Direction() Direction

Direction returns the sorting direction.

func (Order) Get

func (o Order) Get() string

Get returns the SQL fragment for the order clause (e.g., "column asc").

func (Order) IsValid

func (o Order) IsValid() error

IsValid validates the Order, ensuring direction is 'asc' or 'desc' and column is not empty.

Jump to

Keyboard shortcuts

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