query

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUM     = "SUM"
	COUNT   = "COUNT"
	MIN     = "MIN"
	MAX     = "MAX"
	AVERAGE = "AVG"
)
View Source
const (
	// Equal is a Comparison operator
	Equal Operator = "=="

	// And is a Comparison operator
	And = "AND"

	// Or is a Comparison operator
	Or = "OR"

	// In is a Comparison operator
	In = "In"
)

Variables

This section is empty.

Functions

func IsGroupOperator

func IsGroupOperator(o Operator) bool

IsGroupOperator says if an operator is a group operator

Types

type Column

type Column struct {
	Alias      string     `json:"alias"`
	Expression Expression `json:"expression"`
}

Column reference a column in a SELECT statement

func AverageAs

func AverageAs(expression Expression, alias string) Column

AverageAs returns average value for a given expression

func Columns

func Columns(names ...string) []Column

Columns shortcut for creating slice of columns by names

func CountAs

func CountAs(expression Expression, alias string) Column

CountAs aggregate function (see SQL COUNT())

func MaxAs

func MaxAs(expression Expression, alias string) Column

MaxAs returns maximum value for a given expression

func MinAs

func MinAs(expression Expression, alias string) Column

MinAs returns minimum value for a given expression

func SumAs

func SumAs(expression Expression, alias string) Column

SumAs aggregate function (see SQL SUM())

func (Column) String

func (v Column) String() string

String stringifies column value

type Comparison

type Comparison struct {
	Operator    Operator     `json:"operator"`
	Expressions []Expression `json:"expressions"`
}

Comparison defines a contact for a comparison

func NewComparison

func NewComparison(o Operator, expressions ...Expression) Comparison

NewComparison creates new Comparison

func (Comparison) String

func (v Comparison) String() string

String returns string representation of a comparison

type Condition

type Condition interface {
	fmt.Stringer
}

Condition holds condition definition

type Expression

type Expression interface {
	fmt.Stringer
}

Expression represent either a field, constant or a formula

func Field

func Field(name string) Expression

Field creates an expression that represents a field value

func ID

func ID(name string, value interface{}) Expression

ID creates an expression that compares an ID with a constant

func String

func String(v string) Expression

String creates a new constant expression

type Operator

type Operator string

Operator defines a Comparison operator

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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