query

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPageOffset = 0
	DefaultPageSize   = 20
)
View Source
const (
	OpAnd       = Op("AND")
	OpOr        = Op("OR")
	OpNot       = Op("NOT")
	OpEq        = Op("=")
	OpIsNull    = Op("IS NULL")
	OpIsNotNull = Op("IS NOT NULL")
	OpGt        = Op(">")
	OpLt        = Op("<")
	OpNe        = Op("<>")
	OpNe2       = Op("!=")
	OpIn        = Op("IN")
	OpLike      = Op("LIKE")
	OpNotLike   = Op("NOT LIKE")
)

Variables

View Source
var (
	DefaultPaging           = Page(DefaultPageOffset, DefaultPageSize)
	DefaultFilter           = SimpleExpr("1", OpAnd, "1")
	DefaultQuery  Interface = &qryData{
		paging: DefaultPaging,
	}
)

Functions

func EncodeFilter

func EncodeFilter(fe FilterExpression) ([]byte, error)

func EncodeRequest

func EncodeRequest(req *http.Request, qry Interface) error

func ToParams added in v1.0.3

func ToParams(params Interface) (*api.ListItemsParams, error)

Types

type BetweenExpression added in v1.0.7

type BetweenExpression interface {
	Name() string
	Left() interface{}
	Right() interface{}
}

type Builder added in v1.0.4

type Builder interface {
	OrderBy(string, bool) Builder
	Paging(int, int) Builder
	Filter(FilterExpression) Builder
	Build() Interface
}

func NewBuilder added in v1.0.4

func NewBuilder() Builder

type FilterBetweenExpression added in v1.0.7

type FilterBetweenExpression struct {
	Left  interface{} `json:"left"`
	Name  string      `json:"name"`
	Right interface{} `json:"right"`
}

func (*FilterBetweenExpression) AsFilterExpression added in v1.0.7

func (e *FilterBetweenExpression) AsFilterExpression() FilterExpression

type FilterExpression

type FilterExpression interface {
	fmt.Stringer
}

func BetweenExpr added in v1.0.7

func BetweenExpr(name string, left interface{}, right interface{}) FilterExpression

func DecodeFilter

func DecodeFilter(str string) (FilterExpression, error)

func In added in v1.0.7

func In(name string, vals []interface{}) FilterExpression

func Junction

func Junction(op Op, sub ...FilterExpression) FilterExpression

func Not

func SimpleExpr

func SimpleExpr(name string, op Op, val interface{}) FilterExpression

func UnaryExpr added in v1.0.7

func UnaryExpr(name string, op Op) FilterExpression

type FilterExpressionWrapper added in v1.0.7

type FilterExpressionWrapper struct {
	Between  *FilterBetweenExpression  `json:"between,omitempty"`
	In       *FilterInExpression       `json:"in,omitempty"`
	Junction *FilterJunctionExpression `json:"junction,omitempty"`
	Not      *FilterNotExpression      `json:"not,omitempty"`
	Simple   *FilterSimpleExpression   `json:"simple,omitempty"`
	Un       *FilterUnExpression       `json:"un,omitempty"`
}

func (*FilterExpressionWrapper) AsFilterExpression added in v1.0.7

func (few *FilterExpressionWrapper) AsFilterExpression() FilterExpression

type FilterInExpression added in v1.0.7

type FilterInExpression struct {
	Name string        `json:"name"`
	Val  []interface{} `json:"val"`
}

func (*FilterInExpression) AsFilterExpression added in v1.0.7

func (e *FilterInExpression) AsFilterExpression() FilterExpression

type FilterJunctionExpression added in v1.0.7

type FilterJunctionExpression struct {
	Op  string                    `json:"op"`
	Sub []FilterExpressionWrapper `json:"sub"`
}

func (*FilterJunctionExpression) AsFilterExpression added in v1.0.7

func (e *FilterJunctionExpression) AsFilterExpression() FilterExpression

type FilterNotExpression added in v1.0.7

type FilterNotExpression struct {
	Sub FilterExpressionWrapper `json:"sub"`
}

func (*FilterNotExpression) AsFilterExpression added in v1.0.7

func (e *FilterNotExpression) AsFilterExpression() FilterExpression

type FilterSimpleExpression added in v1.0.7

type FilterSimpleExpression struct {
	Name string      `json:"name"`
	Op   string      `json:"op"`
	Val  interface{} `json:"val"`
}

func (*FilterSimpleExpression) AsFilterExpression added in v1.0.7

func (e *FilterSimpleExpression) AsFilterExpression() FilterExpression

type FilterUnExpression added in v1.0.7

type FilterUnExpression struct {
	Name string `json:"name"`
	Op   string `json:"op"`
}

func (*FilterUnExpression) AsFilterExpression added in v1.0.7

func (e *FilterUnExpression) AsFilterExpression() FilterExpression

type InExpression added in v1.0.7

type InExpression interface {
	Name() string
	Values() []interface{}
}

type Interface

type Interface interface {
	fmt.Stringer
	Orders() Orders
	Paging() Paging
	Filter() FilterExpression
}

func FromParams

func FromParams(pPageOffset *api.PageOffset, pPageSize *api.PageSize, pOrders *[]string, pFilter *string) (Interface, error)

type JunctionExpression added in v1.0.7

type JunctionExpression interface {
	Op() Op
	Sub() []FilterExpression
}

type NotExpression added in v1.0.7

type NotExpression interface {
	Sub() FilterExpression
}

type Op

type Op string

type Order

type Order interface {
	Name() string
	Asc() bool
}

func OrderBy

func OrderBy(name string, asc bool) Order

type Orders

type Orders []Order

func (Orders) String

func (o Orders) String() string

type Paging

type Paging interface {
	fmt.Stringer
	Offset() uint64
	Size() int
}

func Page

func Page(offset uint64, count int) Paging

type SimpleExpression added in v1.0.7

type SimpleExpression interface {
	Name() string
	Op() Op
	Value() interface{}
}

type UnaryExpression added in v1.0.7

type UnaryExpression interface {
	Name() string
	Op() Op
}

UnaryExpression <prop> IS NULL / <prop> IS NOT NULL

Jump to

Keyboard shortcuts

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