query

package
v1.13.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 2 Imported by: 7

Documentation

Index

Constants

View Source
const (
	FILTER = "filter"
	SORT   = "sort"
	PAGE   = "page"
	ASC    = "ASC"
	DESC   = "DESC"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AND

type AND struct {
	Filters []Filter
}

func (*AND) Parse

func (f *AND) Parse(obj interface{}) (err error)

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func NewQueryBuilder

func NewQueryBuilder(visitor Visitor) *Builder

func (*Builder) BuildQuery

func (h *Builder) BuildQuery(q *Query) error

type EQ

type EQ struct {
	Key string
	Val interface{}
}

func (*EQ) Parse

func (f *EQ) Parse(obj interface{}) error

type Filter

type Filter interface {
	Parse(interface{}) error
}

func ParseFilter added in v1.10.1

func ParseFilter(obj interface{}) (Filter, error)

ParseFilter parses a filter struct using the visitor pattern returning a built Filter interface.

type GT added in v1.13.0

type GT struct {
	Key string
	Val interface{}
}

func (*GT) Parse added in v1.13.0

func (f *GT) Parse(obj interface{}) error

type GTE added in v1.13.0

type GTE struct {
	Key string
	Val interface{}
}

func (*GTE) Parse added in v1.13.0

func (f *GTE) Parse(obj interface{}) error

type IN

type IN struct {
	Key  string
	Vals []interface{}
}

func (*IN) Parse

func (f *IN) Parse(obj interface{}) error

type LT added in v1.13.0

type LT struct {
	Key string
	Val interface{}
}

func (*LT) Parse added in v1.13.0

func (f *LT) Parse(obj interface{}) error

type LTE added in v1.13.0

type LTE struct {
	Key string
	Val interface{}
}

func (*LTE) Parse added in v1.13.0

func (f *LTE) Parse(obj interface{}) error

type NEQ added in v1.13.0

type NEQ struct {
	Key string
	Val interface{}
}

func (*NEQ) Parse added in v1.13.0

func (f *NEQ) Parse(obj interface{}) error

type OR

type OR struct {
	Filters []Filter
}

func (*OR) Parse

func (f *OR) Parse(obj interface{}) (err error)

type Pagination

type Pagination struct {
	Limit int    `json:"limit"`
	Token string `json:"token,omitempty"`
}

type Query

type Query struct {
	QueryFields `json:",inline"`

	// derived from Filters
	Filter Filter
}

func (*Query) UnmarshalJSON

func (q *Query) UnmarshalJSON(data []byte) error

type QueryFields added in v1.9.0

type QueryFields struct {
	Filters map[string]interface{} `json:"filter"`
	Sort    []Sorting              `json:"sort"`
	Page    Pagination             `json:"page"`
}

used only for intermediate query value.

type Sorting

type Sorting struct {
	Key   string `json:"key"`
	Order string `json:"order,omitempty"`
}

type Visitor

type Visitor interface {
	// returns "equal" expression
	VisitEQ(*EQ) (string, error)
	// returns "not equal" expression
	VisitNEQ(*NEQ) (string, error)
	// returns "greater than" expression
	VisitGT(*GT) (string, error)
	// returns "greater than equal" expression
	VisitGTE(*GTE) (string, error)
	// returns "less than" expression
	VisitLT(*LT) (string, error)
	// returns "less than equal" expression
	VisitLTE(*LTE) (string, error)
	// returns "in" expression
	VisitIN(*IN) (string, error)
	// returns "and" expression
	VisitAND(*AND) (string, error)
	// returns "or" expression
	VisitOR(*OR) (string, error)
	// receives concatenated filters and finalizes the native query
	Finalize(string, *Query) error
}

Jump to

Keyboard shortcuts

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