sqlq

package module
v0.0.0-...-7477b53 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: MIT Imports: 5 Imported by: 2

README

SQLQ - SQL query builder from composable parts.

Example

q := sqlq.New("sqlite", true)
query := q.Select("*") + q.From("a") + q.Where(q.Compare("b","=","c")) + q.Limit(10)
// query = "SELECT * FROM a WHERE b = c LIMIT 10"

Available methods:

Select(columns ...interface{}) string 

SelectDistinct(columns ...interface{}) string 

Count(column interface{}) string 

CountDistinct(column interface{}) string 

Into(newTable string) string 

From(tables ...interface{}) string 

Where(conditions ...string) string 

fConditions(conditions ...string) string 

fOrConditions(conditions ...string) string 

Compare(column interface{}, operator string, value interface{}) string 

Between(column, value1, value2 interface{}) 

NotBetween(column, value1, value2 interface{}) string 

IsNull(column interface{}) string 

IsNotNull(column interface{}) string 

// Like : pattern "%?%" ? mark replaced by value
Like(column interface{}, pattern string, value interface{}) string 

NotLike(column interface{}, pattern string, value interface{}) string 

In(column interface{}, values ...interface{}) string 

NotIn(column interface{}, values ...interface{}) string 

OrderBy(column interface{}, order string) string 

GroupBy(columns ...interface{}) string 

Limit(value int) string 

Offset(value int) string 

Paginate(page, perPage int) string 

Join(table, table1Column, table2Column interface{}) string 

InnerJoin(table, table1Column, table2Column interface{}) string 

LeftJoin(table, table1Column, table2Column interface{}) string 

LeftOuterJoin(table, table1Column, table2Column interface{}) string 

RightJoin(table, table1Column, table2Column interface{}) string 

RightOuterJoin(table, table1Column, table2Column interface{}) string 

FullJoin(table, table1Column, table2Column interface{}) string 

FullOuterJoin(table, table1Column, table2Column interface{}) string 

fUnion(selectStatements ...string) string 

fUnionAll(selectStatements ...string) string 

InsertInto(table interface{}, columns Map) string 

Update(table interface{}, columns Map) string 

Delete(table interface{}) string 

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

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

func (*Condition) Else

func (c *Condition) Else(s ...string) string

func (*Condition) ElseIf

func (c *Condition) ElseIf(condition bool, s ...string) *Condition

type Map

type Map map[string]interface{}

type Sqlq

type Sqlq struct {
	Dialect string
	Escape  bool
	// contains filtered or unexported fields
}

func New

func New(dialect string, escape bool) *Sqlq

func (*Sqlq) Between

func (sqlq *Sqlq) Between(column, value1, value2 interface{}) string

func (*Sqlq) Compare

func (sqlq *Sqlq) Compare(column interface{}, operator string, value interface{}) string

func (Sqlq) Concat

func (Sqlq) Concat(queryA ...*query) *query

func (Sqlq) Conditions

func (Sqlq) Conditions(conditions ...string) string

func (*Sqlq) Count

func (sqlq *Sqlq) Count(column interface{}) string

func (*Sqlq) CountDistinct

func (sqlq *Sqlq) CountDistinct(column interface{}) string

func (*Sqlq) Delete

func (sqlq *Sqlq) Delete(table interface{}) string

func (*Sqlq) From

func (sqlq *Sqlq) From(tables ...interface{}) string

func (*Sqlq) FullJoin

func (sqlq *Sqlq) FullJoin(table, table1Column, table2Column interface{}) string

func (*Sqlq) FullOuterJoin

func (sqlq *Sqlq) FullOuterJoin(table, table1Column, table2Column interface{}) string

func (*Sqlq) GroupBy

func (sqlq *Sqlq) GroupBy(columns ...interface{}) string

func (*Sqlq) I

func (sqlq *Sqlq) I(i interface{}, skipEscape ...bool) string

I any type identifier

func (*Sqlq) If

func (sqlq *Sqlq) If(condition bool, s ...string) *Condition

func (*Sqlq) In

func (sqlq *Sqlq) In(column interface{}, values ...interface{}) string

func (*Sqlq) InnerJoin

func (sqlq *Sqlq) InnerJoin(table, table1Column, table2Column interface{}) string

func (*Sqlq) InsertInto

func (sqlq *Sqlq) InsertInto(table interface{}, columns Map) string

func (*Sqlq) Into

func (sqlq *Sqlq) Into(newTable string) string

func (*Sqlq) IsNotNull

func (sqlq *Sqlq) IsNotNull(column interface{}) string

func (*Sqlq) IsNull

func (sqlq *Sqlq) IsNull(column interface{}) string

func (*Sqlq) Join

func (sqlq *Sqlq) Join(table, table1Column, table2Column interface{}) string

func (*Sqlq) L

func (sqlq *Sqlq) L(i interface{}, skipEscape ...bool) string

L any type Literal.

func (*Sqlq) LeftJoin

func (sqlq *Sqlq) LeftJoin(table, table1Column, table2Column interface{}) string

func (*Sqlq) LeftOuterJoin

func (sqlq *Sqlq) LeftOuterJoin(table, table1Column, table2Column interface{}) string

func (*Sqlq) Like

func (sqlq *Sqlq) Like(column interface{}, pattern string, value interface{}) string

Like : pattern "%?%" ? mark replaced by value

func (*Sqlq) Limit

func (sqlq *Sqlq) Limit(value int) string

func (*Sqlq) NotBetween

func (sqlq *Sqlq) NotBetween(column, value1, value2 interface{}) string

func (*Sqlq) NotIn

func (sqlq *Sqlq) NotIn(column interface{}, values ...interface{}) string

func (*Sqlq) NotLike

func (sqlq *Sqlq) NotLike(column interface{}, pattern string, value interface{}) string

func (*Sqlq) O

func (sqlq *Sqlq) O(s string, skipEscape ...bool) string

O order asc or desc.

func (*Sqlq) Offset

func (sqlq *Sqlq) Offset(value int) string

func (Sqlq) OrConditions

func (Sqlq) OrConditions(conditions ...string) string

func (*Sqlq) OrderBy

func (sqlq *Sqlq) OrderBy(column interface{}, order string) string

func (*Sqlq) Paginate

func (sqlq *Sqlq) Paginate(page, perPage int) string

func (Sqlq) Query

func (Sqlq) Query(qParts ...string) *query

func (*Sqlq) Raw

func (sqlq *Sqlq) Raw() *Sqlq

func (*Sqlq) RightJoin

func (sqlq *Sqlq) RightJoin(table, table1Column, table2Column interface{}) string

func (*Sqlq) RightOuterJoin

func (sqlq *Sqlq) RightOuterJoin(table, table1Column, table2Column interface{}) string

func (*Sqlq) Select

func (sqlq *Sqlq) Select(columns ...interface{}) string

func (*Sqlq) SelectDistinct

func (sqlq *Sqlq) SelectDistinct(columns ...interface{}) string

func (*Sqlq) SkipEscapeOnce

func (sqlq *Sqlq) SkipEscapeOnce()

func (*Sqlq) StartEscape

func (sqlq *Sqlq) StartEscape()

func (*Sqlq) StopEscape

func (sqlq *Sqlq) StopEscape()

func (Sqlq) Union

func (Sqlq) Union(selectStatements ...string) string

func (Sqlq) UnionAll

func (Sqlq) UnionAll(selectStatements ...string) string

func (*Sqlq) Update

func (sqlq *Sqlq) Update(table interface{}, columns Map) string

func (*Sqlq) Where

func (sqlq *Sqlq) Where(conditions ...string) string

Jump to

Keyboard shortcuts

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