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{
		"login-asc":          newSortOption("login", false, 0),
		"login-desc":         newSortOption("login", true, 0),
		"email-asc":          newSortOption("email", false, 1),
		"email-desc":         newSortOption("email", true, 1),
		"name-asc":           newSortOption("name", false, 2),
		"name-desc":          newSortOption("name", true, 2),
		"lastSeenAtAge-asc":  newTimeSortOption("last_seen_at", false, 3),
		"lastSeenAtAge-desc": newTimeSortOption("last_seen_at", true, 3),
	}

	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
	Descending 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