query

package
v0.0.0-...-83c7fa4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GroupByOf

func GroupByOf(stmt *SelectStmt) []string

func LimitOf

func LimitOf(stmt *SelectStmt) (int, int)

func OrderByOf

func OrderByOf(stmt *SelectStmt) []string

func StatementOf

func StatementOf(q interface{}) interface{}

func ValueOf

func ValueOf(stmt interface{}) []string

func WhereOf

func WhereOf(stmt interface{}) []string

Types

type Condition

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

func (*Condition) And

func (c *Condition) And(query string) *Condition

func (*Condition) Or

func (c *Condition) Or(query string) *Condition

type Field

type Field struct {
	Name        string
	Alias       string
	Placeholder string //used by update
}

func FieldsOf

func FieldsOf(stmt *SelectStmt) []Field

type GroupBy

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

func (*GroupBy) Limit

func (g *GroupBy) Limit(num ...int) *TableStmt

func (*GroupBy) OrderBy

func (g *GroupBy) OrderBy(orders string) *OrderBy

type InsertStmt

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

func InsertInto

func InsertInto(table string, fields string) *InsertStmt

func (*InsertStmt) Values

func (i *InsertStmt) Values(query string) *InsertStmt

type OrderBy

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

func (*OrderBy) Limit

func (o *OrderBy) Limit(num ...int) *TableStmt

type SelectStmt

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

func ParseSelect

func ParseSelect(query string) *SelectStmt

func Select

func Select(query string) *SelectStmt

func (*SelectStmt) From

func (s *SelectStmt) From(table string) *TableStmt

From table name with or without alias. Ex: Without alias => "Select books.* From books" With alias => "Select b.* From books b"

type Table

type Table struct {
	Name      string
	Alias     string
	Condition string
	Fields    []Field
}

func TableOf

func TableOf(stmt interface{}) Table

type TableStmt

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

func JoinOf

func JoinOf(stmt *TableStmt) *TableStmt

func TableStmtOf

func TableStmtOf(stmt *SelectStmt) *TableStmt

func (*TableStmt) GroupBy

func (t *TableStmt) GroupBy(groupBy string) *GroupBy

func (*TableStmt) InnerJoin

func (t *TableStmt) InnerJoin(table, condition string) *TableStmt

func (*TableStmt) Join

func (t *TableStmt) Join(joinKind, table, condition string) *TableStmt

func (*TableStmt) LeftJoin

func (t *TableStmt) LeftJoin(table, condition string) *TableStmt

func (*TableStmt) Limit

func (t *TableStmt) Limit(num ...int) *TableStmt

Limit used by MySQL. Parameters 'num' can be single int for "LIMIT n" or double for "LIMIT n1, n2" Ex: SELECT * FROM books LIMIT 1. offset = 0, length = 1 SELECT * FROM books LIMIT 0, 10. offset = 0, length = 10

func (*TableStmt) OrderBy

func (t *TableStmt) OrderBy(orders string) *OrderBy

OrderBy query: "title" => Select books.* From books ORDER BY title query: "title DESC" => Select books.* From books ORDER BY title DESC

func (*TableStmt) RightJoin

func (t *TableStmt) RightJoin(table, condition string) *TableStmt

func (*TableStmt) Where

func (t *TableStmt) Where(condition string) *Where

type UpdateStmt

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

func NewUpdate

func NewUpdate(table string) *UpdateStmt

func Update

func Update(table string) *UpdateStmt

func (*UpdateStmt) Set

func (u *UpdateStmt) Set(query string) *UpdateStmt

func (*UpdateStmt) Where

func (u *UpdateStmt) Where(condition string) *Condition

type Where

type Where struct {
	Condition
}

func (*Where) And

func (w *Where) And(query string) *Where

func (*Where) GroupBy

func (w *Where) GroupBy(groupBy string) *GroupBy

func (*Where) Or

func (w *Where) Or(query string) *Where

func (*Where) OrderBy

func (w *Where) OrderBy(orderBy string) *OrderBy

Jump to

Keyboard shortcuts

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