sorting

package module
v0.0.0-...-4c47ab0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: MIT Imports: 20 Imported by: 0

README

Sorting

Sorting is used to add reordering abilities to GORM-backend models and sort collections

GoDoc

Documentation

https://doc.getqor.com/helpers/sorting.html

License

Released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MoveDown

func MoveDown(db *aorm.DB, value sortingInterface, pos int) error

MoveDown move position down

func MoveTo

func MoveTo(db *aorm.DB, value sortingInterface, pos int) error

MoveTo move position to

func MoveUp

func MoveUp(db *aorm.DB, value sortingInterface, pos int) error

MoveUp move position up

func RegisterCallbacks

func RegisterCallbacks(db *aorm.DB)

RegisterCallbacks register callbacks into gorm db instance

Types

type Plugin

type Plugin struct {
	db.DBNames
	plug.EventDispatcher
}

func (*Plugin) OnRegister

func (p *Plugin) OnRegister()

type SortableCollection

type SortableCollection struct {
	PrimaryField string
	PrimaryKeys  []string
}

func (*SortableCollection) ConfigureQorMeta

func (sortableCollection *SortableCollection) ConfigureQorMeta(metaor resource.Metaor)

func (*SortableCollection) Scan

func (sortableCollection *SortableCollection) Scan(value interface{}) error

func (SortableCollection) Sort

func (sortableCollection SortableCollection) Sort(results interface{}) error

func (SortableCollection) Value

func (sortableCollection SortableCollection) Value() (driver.Value, error)

type Sorting

type Sorting struct {
	Position int `sql:"DEFAULT:NULL"`
}

Sorting ascending mode

func (*Sorting) ConfigureResource

func (s *Sorting) ConfigureResource(res resource.Resourcer)

ConfigureResource configure sorting for qor admin

func (Sorting) GetPosition

func (position Sorting) GetPosition() int

GetPosition get current position

func (*Sorting) SetPosition

func (position *Sorting) SetPosition(pos int)

SetPosition set position, only set field value, won't save

type SortingDESC

type SortingDESC struct {
	Sorting
}

SortingDESC descending mode

func (SortingDESC) SortingDesc

func (SortingDESC) SortingDesc()

SortingDesc make your model sorting desc by default

Jump to

Keyboard shortcuts

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