query

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: Apache-2.0 Imports: 2 Imported by: 7 modules, 13 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
}

type IN

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

func (*IN) Parse

func (f *IN) 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 {
	Filters map[string]interface{} `json:"filter"`
	Sort    []Sorting              `json:"sort"`
	Page    Pagination             `json:"page"`

	// derived from Filters
	Filter Filter
}

func (*Query) UnmarshalJSON

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

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 "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