ordering

package
v0.67.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 7 Imported by: 6

Documentation

Overview

Package ordering provides primitives for implementing AIP ordering.

See: https://google.aip.dev/132#ordering (Standard methods: List > Ordering).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	// Path is the path of the field, including subfields.
	Path string
	// Desc indicates if the ordering of the field is descending.
	Desc bool
}

Field represents a single ordering field.

func (Field) SubFields

func (f Field) SubFields() []string

SubFields returns the individual subfields of the field path, including the top-level subfield.

Subfields are specified with a . character, such as foo.bar or address.street.

type OrderBy

type OrderBy struct {
	// Fields are the fields to order by.
	Fields []Field
}

OrderBy represents an ordering directive.

func ParseOrderBy

func ParseOrderBy(r Request) (OrderBy, error)

ParseOrderBy request parses the ordering field for a Request.

func (*OrderBy) UnmarshalString

func (o *OrderBy) UnmarshalString(s string) error

UnmarshalString sets o from the provided ordering string. .

func (OrderBy) ValidateForMessage added in v0.13.0

func (o OrderBy) ValidateForMessage(m proto.Message) error

ValidateForMessage validates that the ordering paths are syntactically valid and refer to known fields in the specified message type.

func (OrderBy) ValidateForPaths added in v0.12.0

func (o OrderBy) ValidateForPaths(paths ...string) error

ValidateForPaths validates that the ordering paths are syntactically valid and refer to one of the provided paths.

type Request

type Request interface {
	// GetOrderBy returns the ordering of the request.
	GetOrderBy() string
}

Request is an interface for requests that support ordering.

See: https://google.aip.dev/132#ordering (Standard methods: List > Ordering).

Jump to

Keyboard shortcuts

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