sortopts

package
v11.1.4-modfix Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SortOptionsByQueryParam is a map to translate the "sort" query param values to SortOption(s)
	SortOptionsByQueryParam = map[string]model.SortOption{
		"userAgent-asc":  newSortOption("user_agent", false, 0),
		"userAgent-desc": newSortOption("user_agent", true, 0),
		"updatedAt-asc":  newTimeSortOption("updated_at", false, 1),
		"updatedAt-desc": newTimeSortOption("updated_at", true, 2),
	}

	ErrorUnknownSortingOption = errutil.BadRequest("unknown sorting option")
)

Functions

func ParseSortQueryParam

func ParseSortQueryParam(param string) ([]model.SortOption, error)

ParseSortQueryParam parses the "sort" query param and returns an ordered list of SortOption(s)

Types

type Sorter

type Sorter struct {
	Field         string
	LowerCase     bool
	Descending    bool
	WithTableName bool
}

func (Sorter) OrderBy

func (s Sorter) OrderBy() string

Jump to

Keyboard shortcuts

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