query

package
v0.2.3-alpha Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder interface {
	Where(field string, op Operator, value any) Builder
	WhereEq(field string, value any) Builder
	WhereNotEq(field string, value any) Builder
	WhereLt(field string, value any) Builder
	WhereLtEq(field string, value any) Builder
	WhereGt(field string, value any) Builder
	WhereGtEq(field string, value any) Builder
	WhereLike(field string, value any) Builder
	WhereNotLike(field string, value any) Builder
	WhereIn(field string, value any) Builder
	WhereNotIn(field string, value any) Builder
	WhereIs(field string, value any) Builder
	WhereNotIs(field string, value any) Builder
	WhereBetween(field string, valueMin, valueMax any) Builder
	WhereNotBetween(field string, valueMin, valueMax any) Builder

	And(field string, op Operator, value any) Builder
	AndEq(field string, value any) Builder
	AndNotEq(field string, value any) Builder
	AndLt(field string, value any) Builder
	AndLtEq(field string, value any) Builder
	AndGt(field string, value any) Builder
	AndGtEq(field string, value any) Builder
	AndLike(field string, value any) Builder
	AndNotLike(field string, value any) Builder
	AndIn(field string, value any) Builder
	AndNotIn(field string, value any) Builder
	AndIs(field string, value any) Builder
	AndNotIs(field string, value any) Builder
	AndBetween(field string, valueMin, valueMax any) Builder
	AndNotBetween(field string, valueMin, valueMax any) Builder

	Or(field string, op Operator, value any) Builder
	OrEq(field string, value any) Builder
	OrNotEq(field string, value any) Builder
	OrLt(field string, value any) Builder
	OrLtEq(field string, value any) Builder
	OrGt(field string, value any) Builder
	OrGtEq(field string, value any) Builder
	OrLike(field string, value any) Builder
	OrNotLike(field string, value any) Builder
	OrIn(field string, value any) Builder
	OrNotIn(field string, value any) Builder
	OrIs(field string, value any) Builder
	OrNotIs(field string, value any) Builder
	OrBetween(field string, valueMin, valueMax any) Builder
	OrNotBetween(field string, valueMin, valueMax any) Builder

	AndGroup(conditions Filter) Builder
	OrGroup(conditions Filter) Builder

	GetWhere() (string, []any, error)

	Order(field string, dir ...Direction) Builder
	GetOrderBy() string
	GetOrder() *Order

	Limit(int) Builder
	GetLimit() int
	Offset(int) Builder
	GetOffset() int
	Pagination(p *Pagination) Builder
	GetPagination() *Pagination

	Join(query string, args ...any) Builder
	GetJoins() []Join

	Build() (Template, error)
}

func NewQuery added in v0.2.1

func NewQuery() Builder

func NewQueryFromUrl added in v0.2.1

func NewQueryFromUrl(q url.Values) Builder

type Direction added in v0.2.1

type Direction string
const (
	Ascending  Direction = "ASC"
	Descending Direction = "DESC"
)

func DirectionFromString added in v0.2.1

func DirectionFromString(input string) (Direction, error)

type Filter added in v0.2.1

type Filter interface {
	girraph.Tree[Filter]

	Generate() (string, []any, error)

	And(field string, op Operator, value any) Filter
	AndEq(field string, value any) Filter
	AndNotEq(field string, value any) Filter
	AndLt(field string, value any) Filter
	AndLtEq(field string, value any) Filter
	AndGt(field string, value any) Filter
	AndGtEq(field string, value any) Filter
	AndLike(field string, value any) Filter
	AndNotLike(field string, value any) Filter
	AndIn(field string, value any) Filter
	AndNotIn(field string, value any) Filter
	AndIs(field string, value any) Filter
	AndNotIs(field string, value any) Filter
	AndBetween(field string, valueMin, valueMax any) Filter
	AndNotBetween(field string, valueMin, valueMax any) Filter

	Or(field string, op Operator, value any) Filter
	OrEq(field string, value any) Filter
	OrNotEq(field string, value any) Filter
	OrLt(field string, value any) Filter
	OrLtEq(field string, value any) Filter
	OrGt(field string, value any) Filter
	OrGtEq(field string, value any) Filter
	OrLike(field string, value any) Filter
	OrNotLike(field string, value any) Filter
	OrIn(field string, value any) Filter
	OrNotIn(field string, value any) Filter
	OrIs(field string, value any) Filter
	OrNotIs(field string, value any) Filter
	OrBetween(field string, valueMin, valueMax any) Filter
	OrNotBetween(field string, valueMin, valueMax any) Filter

	AndGroup(conditions Filter) Filter
	OrGroup(conditions Filter) Filter
	// contains filtered or unexported methods
}

func NewFilter added in v0.2.1

func NewFilter() Filter

func Where added in v0.2.1

func Where(field string, op Operator, value any) Filter

func WhereBetween

func WhereBetween(field string, valueMin, valueMax any) Filter

func WhereEq added in v0.2.1

func WhereEq(field string, value any) Filter

func WhereGt added in v0.2.1

func WhereGt(field string, value any) Filter

func WhereGtEq added in v0.2.1

func WhereGtEq(field string, value any) Filter

func WhereIn added in v0.2.1

func WhereIn(field string, value any) Filter

func WhereIs

func WhereIs(field string, value any) Filter

func WhereLike added in v0.2.1

func WhereLike(field string, value any) Filter

func WhereLt added in v0.2.1

func WhereLt(field string, value any) Filter

func WhereLtEq added in v0.2.1

func WhereLtEq(field string, value any) Filter

func WhereNotBetween

func WhereNotBetween(field string, valueMin, valueMax any) Filter

func WhereNotEq added in v0.2.1

func WhereNotEq(field string, value any) Filter

func WhereNotIn added in v0.2.1

func WhereNotIn(field string, value any) Filter

func WhereNotIs

func WhereNotIs(field string, value any) Filter

func WhereNotLike added in v0.2.1

func WhereNotLike(field string, value any) Filter

type Join added in v0.2.1

type Join struct {
	Query string
	Args  []any
}

type Logic added in v0.2.1

type Logic string
const (
	And Logic = "AND"
	Or  Logic = "OR"
)

type Operator added in v0.2.1

type Operator string
const (
	Equals             Operator = "="
	NotEqual           Operator = "!="
	LessThan           Operator = "<"
	LessThanEqualTo    Operator = "<="
	GreaterThan        Operator = ">"
	GreaterThanEqualTo Operator = ">="
	Like               Operator = "LIKE"
	NotLike            Operator = "NOT LIKE"
	In                 Operator = "IN"
	NotIn              Operator = "NOT IN"
	Is                 Operator = "IS"
	NotIs              Operator = "IS NOT"
	Between            Operator = "BETWEEN"
	NotBetween         Operator = "NOT BETWEEN"
)

type Order added in v0.2.1

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

func NewOrder added in v0.2.1

func NewOrder() *Order

func NewOrderFromUrl added in v0.2.1

func NewOrderFromUrl(q url.Values) *Order

func (*Order) ApplyToUrl added in v0.2.1

func (o *Order) ApplyToUrl(q url.Values)

func (*Order) By added in v0.2.1

func (o *Order) By(field string, dir ...Direction) *Order

func (*Order) Generate added in v0.2.1

func (o *Order) Generate() string

type Pagination

type Pagination struct {
	Page       int `json:"page,omitempty"`
	PageSize   int `json:"size,omitempty"`
	Total      int `json:"total,omitempty"`
	TotalPages int `json:"pages,omitempty"`
}

func NewPagination

func NewPagination() *Pagination

func NewPaginationFromUrl added in v0.2.1

func NewPaginationFromUrl(q url.Values) *Pagination

func (*Pagination) ApplyToUrl added in v0.2.1

func (p *Pagination) ApplyToUrl(q url.Values)

func (*Pagination) First added in v0.2.1

func (p *Pagination) First() *Pagination

func (*Pagination) GetPage added in v0.2.1

func (p *Pagination) GetPage() int

func (*Pagination) GetPageSize added in v0.2.1

func (p *Pagination) GetPageSize() int

func (*Pagination) GetTotal added in v0.2.1

func (p *Pagination) GetTotal() int

func (*Pagination) GetTotalPages added in v0.2.1

func (p *Pagination) GetTotalPages() int

func (*Pagination) Last added in v0.2.1

func (p *Pagination) Last() *Pagination

func (*Pagination) Next added in v0.2.1

func (p *Pagination) Next() *Pagination

func (*Pagination) Previous added in v0.2.1

func (p *Pagination) Previous() *Pagination

func (*Pagination) SetPage added in v0.2.1

func (p *Pagination) SetPage(page int) *Pagination

func (*Pagination) SetPageSize added in v0.2.1

func (p *Pagination) SetPageSize(size int) *Pagination

func (*Pagination) SetTotal added in v0.2.1

func (p *Pagination) SetTotal(total int) *Pagination

type Template added in v0.2.1

type Template struct {
	Where   string
	Params  []any
	OrderBy string
	Joins   []Join
	Limit   int
	Offset  int
}

Jump to

Keyboard shortcuts

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