query

package
v1.8.9 Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: MIT Imports: 3 Imported by: 0

README

Query

Performance

# https://graphviz.org/download/#mac
brew install graphviz

go test -bench=. ./core/lib/utils/query/testgen/. -cpuprofile cpu.prof
go tool pprof -svg cpu.prof > cpu.svg

go test -bench=. -trace trace.out ./core/lib/utils/query/testgen/.
go tool trace trace.out

# Data Race: Two goroutines access the same variable concurrently 
# and at least one of the accesses is a write 
# https://golang.org/doc/articles/race_detector
go test -race

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Union

func Union(queries ...*Q) (string, error)

Types

type IModel

type IModel interface {
	Table_Name() string
	Table_Columns() []string
	Table_PrimaryKey() string
	Table_PrimaryKey_Value() int64
	Table_InsertColumns() []string
	Table_UpdateColumns() []string
	Table_Column_Types() map[string]string
	String() string
	Update() string
	Create() string
	Destroy() string
	FromID() string
}

type Q

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

func Delete

func Delete(model IModel) *Q

func Insert

func Insert(model IModel) *Q

func Query

func Query(model IModel) *Q

func Select

func Select(model IModel) *Q

func Update

func Update(model IModel) *Q

func (*Q) Alias

func (q *Q) Alias(alias string) *Q

func (*Q) Count

func (q *Q) Count(name, as string) *Q

func (*Q) Field

func (q *Q) Field(name string) *Q

func (*Q) FieldAs

func (q *Q) FieldAs(name, as string) *Q

func (*Q) FieldRaw

func (q *Q) FieldRaw(fieldStr, as string) *Q

func (*Q) Fields

func (q *Q) Fields(fields ...string) *Q

func (*Q) Limit

func (q *Q) Limit(limit, offset int64) *Q

func (*Q) OrderBy

func (q *Q) OrderBy(col, dir string) *Q

func (*Q) Set

func (q *Q) Set(fieldName string, value interface{}) *Q

func (*Q) String

func (q *Q) String() (string, error)

func (*Q) Sum

func (q *Q) Sum(name, as string) *Q

func (*Q) Where

func (q *Q) Where(args ...WherePart) *Q

Where().Equals("a", "b")

type QueryType

type QueryType int
const (
	QueryTypeNotSet QueryType = iota
	QueryTypeSelect
	QueryTypeUpdate
	QueryTypeDelete
	QueryTypeInsert
)

type Where

type Where struct {
	WhereParts []WherePart
	// contains filtered or unexported fields
}

type WherePart

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

func And

func And(args ...WherePart) WherePart

func Between

func Between(fieldName string, from, to interface{}) WherePart

func CommentID

func CommentID(args ...interface{}) WherePart

func EQ

func EQ(fieldName string, value interface{}) WherePart

func EQF

func EQF(fieldName1, fieldName2 string) WherePart

func Exists

func Exists(clause *Q) WherePart

func GT

func GT(fieldName string, value interface{}) WherePart

func GTOE

func GTOE(fieldName string, value interface{}) WherePart

func IN

func IN(fieldName string, values ...interface{}) WherePart

func LT

func LT(fieldName string, value interface{}) WherePart

func LTOE

func LTOE(fieldName string, value interface{}) WherePart

func NE

func NE(fieldName string, value interface{}) WherePart

func NewWherePart

func NewWherePart(whereType WhereType, fieldName string, values []interface{}) WherePart

func Or

func Or(args ...WherePart) WherePart

func PE

func PE() WherePart

Parenthesis End

func PS

func PS() WherePart

Parenthesis Start

type WhereType

type WhereType int
const (
	WhereTypeEquals WhereType = iota
	WhereTypeEqualsField
	WhereTypeNotEquals
	WhereTypeGreaterThan
	WhereTypeLessThan
	WhereTypeGreaterThanOrEqualTo
	WhereTypeLessThanOrEqualTo
	WhereTypeBetween
	WhereTypeIN
	WhereTypeExists
	WhereTypeAnd
	WhereTypeOr
	WhereTypeParenthesisEnd
	WhereTypeParenthesisStart
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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