q

package
v0.0.0-...-21de424 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AndList

type AndList struct {
	Values []interface{}
}

AndList query

func NewAndList

func NewAndList(values []interface{}) *AndList

NewAndList creates a new and list

type FuzzyMatchValue

type FuzzyMatchValue struct {
	Value string
}

FuzzyMatchValue query

func NewFuzzyMatchValue

func NewFuzzyMatchValue(value string) *FuzzyMatchValue

NewFuzzyMatchValue creates a new fuzzy match

type KeyWords

type KeyWords = map[string]interface{}

KeyWords ...

type OrList

type OrList struct {
	Values []interface{}
}

OrList query

func NewOrList

func NewOrList(values []interface{}) *OrList

NewOrList creates a new or list

type Query

type Query struct {
	// Filter list
	Keywords KeyWords
	// Sort list
	Sorts []*Sort
	// Page number
	PageNumber int64
	// Page size
	PageSize int64
	// Deprecate, use "Sorts" instead
	Sorting string
}

Query parameters

func Build

func Build(q, sort string, pageNumber, pageSize int64) (*Query, error)

Build query sting, sort and pagination information into the Query model query string format: q=k=v,k=~v,k=[min~max],k={v1 v2 v3},k=(v1 v2 v3) exact match: k=v fuzzy match: k=~v range: k=[min~max] or list: k={v1 v2 v3} and list: k=(v1 v2 v3) sort format: sort=k1,-k2

func MustClone

func MustClone(query *Query) *Query

MustClone returns the clone of query when it's not nil or returns a new Query instance

func New

func New(kw KeyWords) *Query

New returns Query with keywords

func (*Query) First

func (q *Query) First(sorting ...*Sort) *Query

First make the query only fetch the first one record in the sorting order

type Range

type Range struct {
	Min interface{}
	Max interface{}
}

Range query

func NewRange

func NewRange(min, max interface{}) *Range

NewRange creates a new range

type Sort

type Sort struct {
	Key  string
	DESC bool
}

Sort specifies the order information

func NewSort

func NewSort(key string, desc bool) *Sort

NewSort creates new sort

func ParseSorting

func ParseSorting(sort string) []*Sort

Jump to

Keyboard shortcuts

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