order

package
v0.0.0-...-3ec19d7 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package order provides support for describing the ordering of data.

Index

Constants

View Source
const (
	ASC  = "ASC"
	DESC = "DESC"
)

Set of directions for data ordering.

Variables

This section is empty.

Functions

func Validate

func Validate(field string, direction string) error

Validate checks the field and direction string for sql injection issues.

Types

type By

type By struct {
	Field     string
	Direction string
}

By represents a field used to order by and direction.

func NewBy

func NewBy(field string, direction string) By

NewBy constructs a new By value with no checks.

func (By) IsZeroValue

func (b By) IsZeroValue() bool

IsZeroValue checks if the By value is empty.

type Order

type Order struct {
	Fields  map[string]bool
	Default string
}

Order represents a set of fields that represent the allowable fields for ordering and a default order field.

func New

func New(fields map[string]bool, defaultField string) *Order

New constructs a new Order with a specified set of fields.

func (*Order) By

func (o *Order) By(field string, direction string) (By, error)

By constructs a By value from the specified parameters.

func (*Order) Check

func (o *Order) Check(by By) error

Check validates the order by contains expected values.

Jump to

Keyboard shortcuts

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