sort

package
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultSortStrategy

type DefaultSortStrategy struct{}

func (*DefaultSortStrategy) ApplySort

func (s *DefaultSortStrategy) ApplySort(db *gorm.DB, field, direction string) *gorm.DB

func (*DefaultSortStrategy) Supports

func (s *DefaultSortStrategy) Supports(field string) bool

type RelatedFieldSortStrategy

type RelatedFieldSortStrategy struct {
	FieldPattern string

	OrderClause   string
	AlreadyJoined *bool
	// contains filtered or unexported fields
}

func (*RelatedFieldSortStrategy) ApplySort

func (s *RelatedFieldSortStrategy) ApplySort(db *gorm.DB, field, direction string) *gorm.DB

func (*RelatedFieldSortStrategy) Supports

func (s *RelatedFieldSortStrategy) Supports(field string) bool

type SortOption

type SortOption struct {
	Field     string
	Direction string // "ASC" или "DESC"
}

func NewSortOption

func NewSortOption(field, direction string) *SortOption

func NewSortOptionWithDefaults

func NewSortOptionWithDefaults() *SortOption

func ParseSortString

func ParseSortString(sortStr string, validFields []string) *SortOption

ParseSortString парсит строку сортировки и валидирует поля

func (*SortOption) GetOrderClause

func (o *SortOption) GetOrderClause() string

func (*SortOption) ReplaceFieldIfExists

func (s *SortOption) ReplaceFieldIfExists(oldPart, newPart string) *SortOption

ReplaceFieldIfExists заменяет часть поля сортировки, если она присутствует

type SortStrategy

type SortStrategy interface {
	ApplySort(db *gorm.DB, field, direction string) *gorm.DB
	Supports(field string) bool
}

func NewSortStrategy

func NewSortStrategy(field, tableName string, fi field.FieldInfo, aJ *bool) SortStrategy

Jump to

Keyboard shortcuts

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