query

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrderBy       = "sortBy"
	Ascending     = "ascending"
	Descending    = "descending"
	Limit         = "limit"
	Page          = "page"
	LabelSelector = "labelSelector"
	Details       = "details"
	Type          = "type"
	Source        = "source"
)
View Source
const (
	CreateTime        = "createTime"
	Name              = "name"
	InspectPolicy     = "inspectPolicy"
	Strategy          = "strategy"
	Status            = "status"
	Duration          = "duration"
	Suspend           = "suspend"
	InspectType       = "inspectType"
	LastTaskStatus    = "lastTaskStatus"
	LastTaskStartTime = "lastTaskStartTime"
	StartTimestamp    = "startTimestamp"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter map[string]string

func (*Filter) F

func (f *Filter) F(d []map[string]interface{}, fc filterC) []map[string]interface{}

func (*Filter) Get

func (f *Filter) Get(key string) string

func (*Filter) Keys

func (f *Filter) Keys() (keys []string)

type Pagination

type Pagination struct {
	// items per page
	Limit int
	// offset
	Offset int
}

func NewPagination

func NewPagination() *Pagination

func ParsePagination

func ParsePagination(values url.Values) *Pagination

type Query

type Query struct {
	// pagination
	Pagination *Pagination
	// sort by
	SortBy SortBy
	// sort result in ascending or descending order, default to descending
	Ascending bool
	// filters
	Filters *Filter
	// label selector
	LabelSelector string
}

func NewQuery

func NewQuery() *Query

func ParseQuery

func ParseQuery(g *gin.Context) *Query

func (*Query) GetPageData

func (q *Query) GetPageData(data interface{}, c compare, f filterC) Result

func (*Query) ParseAscending

func (q *Query) ParseAscending(b string) bool

func (*Query) ParseFilter

func (q *Query) ParseFilter(values url.Values) *Filter

type Result

type Result struct {
	// total number of items
	TotalItems int `json:"totalItems,omitempty"`
	// items
	Items interface{} `json:"items"`
}

type SortBy

type SortBy string

func (*SortBy) Asc

func (s *SortBy) Asc(data []map[string]interface{}, c compare)

func (*SortBy) Desc

func (s *SortBy) Desc(data []map[string]interface{}, c compare)

Jump to

Keyboard shortcuts

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