Documentation
¶
Index ¶
- Variables
- type Column
- type ColumnCoalesce
- type ColumnCount
- type ColumnJsonbArrayElementsText
- type ColumnName
- type ColumnValue
- type DeleteQuery
- type Group
- type GroupColumn
- type InsertQuery
- func (q *InsertQuery) Get() (string, map[string]any, error)
- func (q *InsertQuery) OnConflict(c ...string) *InsertQuery
- func (q *InsertQuery) Return(c ...Column) *InsertQuery
- func (q *InsertQuery) UpdateSet(column string, value any) *InsertQuery
- func (q *InsertQuery) UpdateSetNow(column string) *InsertQuery
- func (q *InsertQuery) Value(column string, v any) *InsertQuery
- type On
- type OnAnd
- type OnEq
- type OnLess
- type OnMore
- type Order
- type SelectQuery
- func (q *SelectQuery) Column(c ...Column) *SelectQuery
- func (q *SelectQuery) From(t ...*Table) *SelectQuery
- func (q *SelectQuery) Get() (string, map[string]any, error)
- func (q *SelectQuery) Group(g ...Group) *SelectQuery
- func (q *SelectQuery) IsSub() *SelectQuery
- func (q *SelectQuery) LeftJoin(table *Table, on On) *SelectQuery
- func (q *SelectQuery) Limit(limit int) *SelectQuery
- func (q *SelectQuery) Offset(offset int) *SelectQuery
- func (q *SelectQuery) Order(o ...Order) *SelectQuery
- func (q *SelectQuery) Where(w Where) *SelectQuery
- type Table
- type UpdateQuery
- type Where
- type WhereAnd
- type WhereEq
- type WhereEqColumn
- type WhereExists
- type WhereFullText
- type WhereILike
- type WhereIn
- type WhereIsNotNull
- type WhereIsNull
- type WhereJsonbTextExist
- type WhereJsonbTextInExist
- type WhereLess
- type WhereLessEq
- type WhereMore
- type WhereMoreColumn
- type WhereMoreEq
- type WhereNotEq
- type WhereNotEqColumn
- type WhereOr
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // UpdateNoSets means that when creating update query no set values UpdateNoSets = errors.New("no sets") )
Functions ¶
This section is empty.
Types ¶
type ColumnCoalesce ¶ added in v0.2.0
type ColumnCoalesce struct { Table *Table // required Name string // required Alias string // required Default any // required }
Example ¶
table1 := NewTable("table1") query1 := NewSelect() query1.Column( ColumnCoalesce{Table: table1, Name: "column1", Alias: "a1", Default: 5}, ColumnCoalesce{Table: table1, Name: "column2", Alias: "a2", Default: "text"}, ) query1.From(table1) fmt.Println(query1.Get()) // Result: // SELECT COALESCE(table1_yzethlflca.column1, 5) AS a1, COALESCE(table1_yzethlflca.column2, 'text') AS a2 FROM table1 AS table1_yzethlflca // map[] // <nil>
type ColumnCount ¶ added in v0.2.0
type ColumnCount struct { Table *Table // required Name string Alias string // required Distinct bool }
Example ¶
table1 := NewTable("table1") query1 := NewSelect() query1.Column( ColumnCount{Table: table1, Alias: "a1"}, ColumnCount{Table: table1, Name: "column2", Alias: "a2"}, ColumnCount{Table: table1, Name: "column3", Alias: "a3", Distinct: true}, ) query1.From(table1) fmt.Println(query1.Get()) // Result: // SELECT COUNT(*) AS a1, COUNT(table1_yyapxlsrva.column2) AS a2, COUNT(DISTINCT table1_yyapxlsrva.column3) AS a3 FROM table1 AS table1_yyapxlsrva // map[] // <nil>
type ColumnJsonbArrayElementsText ¶ added in v0.2.1
type ColumnJsonbArrayElementsText struct { Table *Table // required Name string // required Alias string // required Distinct bool }
Example ¶
table1 := NewTable("table1") query1 := NewSelect() query1.Column( ColumnJsonbArrayElementsText{Table: table1, Name: "column1", Alias: "a1"}, ColumnJsonbArrayElementsText{Table: table1, Name: "column2", Alias: "a2", Distinct: true}, ) query1.From(table1) fmt.Println(query1.Get()) // Result: // SELECT JSONB_ARRAY_ELEMENTS_TEXT(table1_yifmeamxwi.column1) AS a1, DISTINCT JSONB_ARRAY_ELEMENTS_TEXT(table1_yifmeamxwi.column2) AS a2 FROM table1 AS table1_yifmeamxwi // map[] // <nil>
type ColumnName ¶ added in v0.2.0
type ColumnName struct { Table *Table // required Name string // required Alias string Distinct bool }
Example ¶
table1 := NewTable("table1") query1 := NewSelect() query1.Column( ColumnName{Table: table1, Name: "column1"}, ColumnName{Table: table1, Name: "column2", Alias: "a2"}, ColumnName{Table: table1, Name: "column3", Distinct: true}, ) query1.From(table1) fmt.Println(query1.Get()) // Result: // SELECT table1_punanojozl.column1, table1_punanojozl.column2 AS a2, DISTINCT table1_punanojozl.column3 FROM table1 AS table1_punanojozl // map[] // <nil>
type ColumnValue ¶ added in v0.2.8
Example ¶
table1 := NewTable("table1") query1 := NewSelect() query1.Column( ColumnValue{Value: 1}, ColumnValue{Value: "1", Alias: "a1"}, ) query1.From(table1) fmt.Println(query1.Get()) // Result: // SELECT 1, '1' AS a1 FROM table1 AS table1_punanojozl // map[] // <nil>
type DeleteQuery ¶
type DeleteQuery struct {
// contains filtered or unexported fields
}
func NewDelete ¶
func NewDelete(table *Table) *DeleteQuery
func (*DeleteQuery) Full ¶
func (q *DeleteQuery) Full() *DeleteQuery
func (*DeleteQuery) Where ¶
func (q *DeleteQuery) Where(w Where) *DeleteQuery
type GroupColumn ¶ added in v0.2.3
type InsertQuery ¶
type InsertQuery struct {
// contains filtered or unexported fields
}
func NewInsert ¶
func NewInsert(table *Table) *InsertQuery
func (*InsertQuery) OnConflict ¶ added in v0.2.6
func (q *InsertQuery) OnConflict(c ...string) *InsertQuery
func (*InsertQuery) Return ¶ added in v0.2.0
func (q *InsertQuery) Return(c ...Column) *InsertQuery
func (*InsertQuery) UpdateSet ¶ added in v0.2.6
func (q *InsertQuery) UpdateSet(column string, value any) *InsertQuery
func (*InsertQuery) UpdateSetNow ¶ added in v0.2.6
func (q *InsertQuery) UpdateSetNow(column string) *InsertQuery
func (*InsertQuery) Value ¶
func (q *InsertQuery) Value(column string, v any) *InsertQuery
type SelectQuery ¶
type SelectQuery struct {
// contains filtered or unexported fields
}
func NewSelect ¶
func NewSelect() *SelectQuery
Example ¶
table1 := NewTable("table1") query1 := NewSelect() query1.Column(ColumnName{Table: table1, Name: "column1"}) query1.From(table1) fmt.Println(query1.Get()) // Result: // SELECT table1_pdddspkqfu.column1 FROM table1 AS table1_pdddspkqfu // map[] // <nil>
func (*SelectQuery) Column ¶
func (q *SelectQuery) Column(c ...Column) *SelectQuery
func (*SelectQuery) From ¶
func (q *SelectQuery) From(t ...*Table) *SelectQuery
func (*SelectQuery) Group ¶ added in v0.2.3
func (q *SelectQuery) Group(g ...Group) *SelectQuery
func (*SelectQuery) IsSub ¶ added in v0.2.8
func (q *SelectQuery) IsSub() *SelectQuery
func (*SelectQuery) LeftJoin ¶
func (q *SelectQuery) LeftJoin(table *Table, on On) *SelectQuery
func (*SelectQuery) Limit ¶
func (q *SelectQuery) Limit(limit int) *SelectQuery
func (*SelectQuery) Offset ¶
func (q *SelectQuery) Offset(offset int) *SelectQuery
func (*SelectQuery) Order ¶
func (q *SelectQuery) Order(o ...Order) *SelectQuery
func (*SelectQuery) Where ¶
func (q *SelectQuery) Where(w Where) *SelectQuery
type Table ¶
func NewTableSub ¶ added in v0.2.3
func NewTableSub(q query) *Table
Using Query as subquery in FROM
Example ¶
table1 := NewTable("table1") query1 := NewSelect() query1.Column(ColumnName{Table: table1, Name: "column1"}) query1.From(table1) table2 := NewTableSub(query1) query2 := NewSelect() query2.Column(ColumnName{Table: table2, Name: "column2"}) query2.From(table2) fmt.Println(query2.Get()) // Result: // SELECT yccakzcfbx_dxaolgmqrw.column2 FROM (SELECT table1_fmxwghcgnt.column1 FROM table1 AS table1_fmxwghcgnt) AS yccakzcfbx_dxaolgmqrw // map[] // <nil>
type UpdateQuery ¶
type UpdateQuery struct {
// contains filtered or unexported fields
}
func NewUpdate ¶
func NewUpdate(table *Table) *UpdateQuery
func (*UpdateQuery) Return ¶ added in v0.2.9
func (q *UpdateQuery) Return(c ...Column) *UpdateQuery
func (*UpdateQuery) Set ¶
func (q *UpdateQuery) Set(column string, value any) *UpdateQuery
func (*UpdateQuery) SetNow ¶
func (q *UpdateQuery) SetNow(column string) *UpdateQuery
func (*UpdateQuery) Where ¶
func (q *UpdateQuery) Where(w Where) *UpdateQuery
type WhereEqColumn ¶ added in v0.2.8
type WhereExists ¶ added in v0.2.8
type WhereExists struct {
Query *SelectQuery
}
type WhereFullText ¶
type WhereILike ¶
type WhereIsNotNull ¶
type WhereIsNull ¶
type WhereJsonbTextExist ¶ added in v0.2.1
type WhereJsonbTextInExist ¶ added in v0.2.4
type WhereLessEq ¶
type WhereMoreColumn ¶
type WhereMoreEq ¶
type WhereNotEq ¶ added in v0.2.10
type WhereNotEqColumn ¶ added in v0.2.10
Click to show internal directories.
Click to hide internal directories.