sorts

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package sorts contains query field sorting structures.

Index

Constants

This section is empty.

Variables

View Source
var MaxNestedRelLevel = 1

MaxNestedRelLevel is a temporary maximum nested check while creating sort fields TODO: change the variable into config settable.

Functions

This section is empty.

Types

type Order

type Order int

Order is an enumerator that describes the order of sorting.

const (
	// AscendingOrder is the enum defines ascending sorting order.
	AscendingOrder Order = iota

	// DescendingOrder is the enum that defines descending sorting order.
	DescendingOrder
)

func (Order) String

func (o Order) String() string

String implements Stringer interface.

type SortField

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

SortField is a field that describes the sorting rules for given query.

func Copy

func Copy(s *SortField) *SortField

Copy copies provided SortField.

func New added in v0.5.1

func New(m *models.ModelStruct, sort string, disallowFK bool, order ...Order) (*SortField, error)

New creates new SortField based on the provided model 'm', string 'sort', flag 'disallowFK' - which doesn't allow to create foreign keys, and optional order.

func NewSortField

func NewSortField(sField *models.StructField, o Order, subs ...*SortField) *SortField

NewSortField creates new SortField with given models.StructField 'sField', order 'o' and sub sort fields: 'subs'.

func NewUniques added in v0.5.1

func NewUniques(m *models.ModelStruct, disallowFK bool, sorts ...string) ([]*SortField, error)

NewUniques creates new unique sort fiellds for provided model 'm'.

func (*SortField) Order

func (s *SortField) Order() Order

Order gets the sort field's order.

func (*SortField) SetSubfield added in v0.2.1

func (s *SortField) SetSubfield(sortSplitted []string, order Order, disallowFK bool) errors.DetailedError

SetSubfield sets the subfield for given sortfield.

func (*SortField) StructField

func (s *SortField) StructField() *models.StructField

StructField returns sortField's model.StructField.

func (*SortField) SubFields added in v0.5.1

func (s *SortField) SubFields() []*SortField

SubFields returns sortFields nested sort fields.

Jump to

Keyboard shortcuts

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