conditions

package
v1.2.84 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	AND = Operation("AND")
	OR  = Operation("OR")
)
View Source
const (
	Equal            = Operator("=")
	NotEqual         = Operator("<>")
	GreatThan        = Operator(">")
	GreatThanOrEqual = Operator(">=")
	LessThan         = Operator("<")
	LessThanOrEqual  = Operator("<=")
	BETWEEN          = Operator("BETWEEN")
	IN               = Operator("IN")
	NOTIN            = Operator("NOT IN")
	LIKE             = Operator("LIKE")
)
View Source
const (
	AVG   = "AVG"
	SUM   = "SUM"
	COUNT = "COUNT"
	MAX   = "MAX"
	MIN   = "MIN"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

type Condition struct {
	Operation Operation
	Left      Node
	Right     Node
	Group     bool
}

Condition tree

func New

func New(predicate Predicate) Condition

func (Condition) And

func (cond Condition) And(right Node) (n Condition)

func (Condition) Exist

func (cond Condition) Exist() bool

func (Condition) Or

func (cond Condition) Or(right Node) (n Condition)

type Literal

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

func Bool

func Bool(b bool) Literal

func Date

func Date(t times.Date) Literal

func Datetime

func Datetime(t time.Time) Literal

func Float

func Float(f float32) Literal

func Float64

func Float64(f float64) Literal

func Int

func Int(n int) Literal

func Int64

func Int64(n int64) Literal

func Lit

func Lit(v string) Literal

func Null

func Null() Literal

func String

func String(s string) Literal

func Time

func Time(t times.Time) Literal

func (Literal) Bytes

func (lit Literal) Bytes() []byte

func (Literal) String

func (lit Literal) String() string

func (Literal) Value

func (lit Literal) Value() string

type Node

type Node interface {
	// contains filtered or unexported methods
}

type Operation

type Operation string

func (Operation) String

func (op Operation) String() string

type Operator

type Operator string

func (Operator) Bytes

func (op Operator) Bytes() []byte

func (Operator) String

func (op Operator) String() string

type Predicate

type Predicate struct {
	Field      string
	Operator   Operator
	Expression any
}

func Between

func Between(field string, left any, right any) Predicate

func Eq

func Eq(field string, expression any) Predicate

func Gt

func Gt(field string, expression any) Predicate

func Gte

func Gte(field string, expression any) Predicate

func In

func In(field string, expression ...any) Predicate

func Like

func Like(field string, expression string) Predicate

func LikeContains

func LikeContains(field string, expression string) Predicate

func LikeLast

func LikeLast(field string, expression string) Predicate

func Lt

func Lt(field string, expression any) Predicate

func Lte

func Lte(field string, expression any) Predicate

func NotEq

func NotEq(field string, expression any) Predicate

func NotIn

func NotIn(field string, expression ...any) Predicate

type QueryExpr

type QueryExpr struct {
	Query     any
	Aggregate string
	Field     string
	Cond      Condition
}

func AggregateQuery

func AggregateQuery(query any, aggregate string, field string, cond Condition) QueryExpr

func LitQuery

func LitQuery(query string) QueryExpr

func Query

func Query(query any, field string, cond Condition) QueryExpr

Jump to

Keyboard shortcuts

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