sqlbuilder

package module
v0.0.0-...-d5910c0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Query

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

Query describes an sql query.

func NewQuery

func NewQuery(table string) *Query

NewQuery returns new Query with table.

func (*Query) Args

func (q *Query) Args() []interface{}

Args returns query arguments.

func (*Query) Delete

func (q *Query) Delete() *Statement

Delete returns sql delete statement.

func (*Query) Insert

func (q *Query) Insert(columns []string, values ...interface{}) *Statement

Insert returns sql insert statement.

func (*Query) Raw

func (q *Query) Raw(str string, args ...interface{}) *Query

Raw wirtes raw string to query and appends args to query arguments.

func (*Query) Reset

func (q *Query) Reset()

Reset resets query string and arguments.

func (*Query) Select

func (q *Query) Select(columns ...string) *Statement

Select returns sql select statement.

func (*Query) SetDriver

func (q *Query) SetDriver(driver string)

SetDriver sets driver field to the given value. SetDriver panics if driver is not supported.

func (*Query) SetTable

func (q *Query) SetTable(table string)

SetTable sets table field and calls Reset.

func (*Query) String

func (q *Query) String() string

String returns query string.

func (*Query) Table

func (q *Query) Table() string

Table returns table name.

func (*Query) Update

func (q *Query) Update(data interface{}, args ...interface{}) *Statement

Update returns sql update statement. data type could be string or map[string]interface{}.

type Statement

type Statement struct {
	*Query
}

Statement describes an sql query statement.

func (*Statement) Limit

func (s *Statement) Limit(n int) *Statement

Limit adds sql limit to query.

Limit panics if n <= 0.

func (*Statement) Offset

func (s *Statement) Offset(n int) *Statement

Offset adds sql offset to query.

Offset panics if n <= 0.

func (*Statement) OrderBy

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

OrderBy adds sql order by columns asc to query.

func (*Statement) OrderByDesc

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

OrderByDesc adds sql order by columns desc to query.

func (*Statement) Returning

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

Returning adds sql returning to query. Should be used with insert or update.

func (*Statement) Where

func (s *Statement) Where(cond string, args ...interface{}) *Statement

Where adds sql where condition to query.

Jump to

Keyboard shortcuts

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