builder

package
v0.0.0-...-608c3ca Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2019 License: Apache-2.0 Imports: 2 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 {
	Prepare(Query) error
}

Builder defines a interface to

func And

func And(cond ...Builder) Builder

And creates AND from a list of conditions.

func Equal

func Equal(column string, value interface{}) Builder

Equal crates a equal comparison

func GreaterOrEqual

func GreaterOrEqual(column string, value interface{}) Builder

GreaterOrEqual greater or equal condition

func GreaterThen

func GreaterThen(column string, value interface{}) Builder

GreaterThen greater then condition

func LowerOrEqual

func LowerOrEqual(column string, value interface{}) Builder

LowerOrEqual lower or equal condition

func LowerThen

func LowerThen(column string, value interface{}) Builder

LowerThen lower then condition

func NotEqual

func NotEqual(column string, value interface{}) Builder

NotEqual creates a not equal comparison

func Or

func Or(cond ...Builder) Builder

Or creates OR from a list of conditions.

func Raw

func Raw(query string, value ...interface{}) Builder

Raw allows a manually created query to be used when current SQL syntax is not supported

type PrepareFunc

type PrepareFunc func(Query) error

PrepareFunc function to assemble queries

func (PrepareFunc) Prepare

func (p PrepareFunc) Prepare(query Query) error

Prepare creates the chain to build the query

type Query

type Query interface {
	WriteString(string) (int, error)
	String() string
	Reset()

	WriteValue(v ...interface{}) (err error)
	Value() []interface{}
}

Query with string builder

func NewQuery

func NewQuery() Query

NewQuery creates a new Query.

type Statement

type Statement struct {
	Type          string
	Table         string
	Columns       []string
	WhereCond     Builder
	JoinTable     []Builder
	Data          []interface{}
	ReturnColumns []string
}

Statement represents a sql query

func Delete

func Delete(table string) *Statement

Delete returns a statement

func Insert

func Insert(table string, columns ...string) *Statement

Insert returns a statement

func Select

func Select(columns ...string) *Statement

Select returns a statement with columns

func Update

func Update(table string, columns ...string) *Statement

Update returns a statement with columns

func (*Statement) From

func (s *Statement) From(table string) *Statement

From defines statement from table

func (*Statement) Join

func (s *Statement) Join(table, on string) *Statement

Join add foreng table with inner join

func (*Statement) Prepare

func (s *Statement) Prepare(q Query) error

Prepare build the query that will be executed

func (*Statement) Return

func (s *Statement) Return(columns ...string) *Statement

Return include in insert statement the return columns

func (*Statement) Values

func (s *Statement) Values(values ...interface{}) *Statement

Values defines the input data to insert and update

func (*Statement) Where

func (s *Statement) Where(conditions interface{}, values ...interface{}) *Statement

Where adds a where condition. query can be Builder or string. value is used only if where type is string.

Jump to

Keyboard shortcuts

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