Documentation
¶
Index ¶
- type DeleteBuilder
- func (b *DeleteBuilder) All(dest interface{}) error
- func (b *DeleteBuilder) Exec() (interface{}, error)
- func (b *DeleteBuilder) Returning(columns ...string) *DeleteBuilder
- func (b *DeleteBuilder) ToSQL() (string, []interface{}, error)
- func (b *DeleteBuilder) Where(condition expr.Expr) *DeleteBuilder
- type InsertBuilder
- func (b *InsertBuilder) Exec() (interface{}, error)
- func (b *InsertBuilder) One(dest interface{}) error
- func (b *InsertBuilder) Returning(columns ...string) *InsertBuilder
- func (b *InsertBuilder) Set(column string, value interface{}) *InsertBuilder
- func (b *InsertBuilder) ToSQL() (string, []interface{}, error)
- func (b *InsertBuilder) Values(data interface{}) *InsertBuilder
- type JoinClause
- type OrderByClause
- type SelectBuilder
- func (b *SelectBuilder) All(dest interface{}) error
- func (b *SelectBuilder) Count() (int64, error)
- func (b *SelectBuilder) Distinct() *SelectBuilder
- func (b *SelectBuilder) GroupBy(columns ...string) *SelectBuilder
- func (b *SelectBuilder) Having(condition expr.Expr) *SelectBuilder
- func (b *SelectBuilder) Join(table interface{}, condition expr.Expr) *SelectBuilder
- func (b *SelectBuilder) LeftJoin(table interface{}, condition expr.Expr) *SelectBuilder
- func (b *SelectBuilder) Limit(limit int) *SelectBuilder
- func (b *SelectBuilder) Offset(offset int) *SelectBuilder
- func (b *SelectBuilder) One(dest interface{}) error
- func (b *SelectBuilder) OrderBy(column string) *SelectBuilder
- func (b *SelectBuilder) OrderByDesc(column string) *SelectBuilder
- func (b *SelectBuilder) RightJoin(table interface{}, condition expr.Expr) *SelectBuilder
- func (b *SelectBuilder) Select(columns ...string) *SelectBuilder
- func (b *SelectBuilder) ToSQL() (string, []interface{}, error)
- func (b *SelectBuilder) Where(condition expr.Expr) *SelectBuilder
- type SessionInterface
- type UpdateBuilder
- func (b *UpdateBuilder) Exec() (interface{}, error)
- func (b *UpdateBuilder) One(dest interface{}) error
- func (b *UpdateBuilder) Returning(columns ...string) *UpdateBuilder
- func (b *UpdateBuilder) Set(column string, value interface{}) *UpdateBuilder
- func (b *UpdateBuilder) ToSQL() (string, []interface{}, error)
- func (b *UpdateBuilder) Where(condition expr.Expr) *UpdateBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeleteBuilder ¶
type DeleteBuilder struct {
// contains filtered or unexported fields
}
DeleteBuilder builds DELETE queries
func NewDelete ¶
func NewDelete(session SessionInterface, table interface{}) *DeleteBuilder
NewDelete creates a new DELETE builder
func (*DeleteBuilder) All ¶
func (b *DeleteBuilder) All(dest interface{}) error
All executes the DELETE with RETURNING and returns all deleted rows
func (*DeleteBuilder) Exec ¶
func (b *DeleteBuilder) Exec() (interface{}, error)
Exec executes the DELETE and returns the result
func (*DeleteBuilder) Returning ¶
func (b *DeleteBuilder) Returning(columns ...string) *DeleteBuilder
Returning specifies which columns to return
func (*DeleteBuilder) ToSQL ¶
func (b *DeleteBuilder) ToSQL() (string, []interface{}, error)
ToSQL generates the SQL query and arguments
func (*DeleteBuilder) Where ¶
func (b *DeleteBuilder) Where(condition expr.Expr) *DeleteBuilder
Where adds a WHERE condition
type InsertBuilder ¶
type InsertBuilder struct {
// contains filtered or unexported fields
}
InsertBuilder builds INSERT queries
func NewInsert ¶
func NewInsert(session SessionInterface, table interface{}) *InsertBuilder
NewInsert creates a new INSERT builder
func (*InsertBuilder) Exec ¶
func (b *InsertBuilder) Exec() (interface{}, error)
Exec executes the INSERT and returns the result
func (*InsertBuilder) One ¶
func (b *InsertBuilder) One(dest interface{}) error
One executes the INSERT with RETURNING and scans into dest
func (*InsertBuilder) Returning ¶
func (b *InsertBuilder) Returning(columns ...string) *InsertBuilder
Returning specifies which columns to return
func (*InsertBuilder) Set ¶
func (b *InsertBuilder) Set(column string, value interface{}) *InsertBuilder
Set sets a specific column value
func (*InsertBuilder) ToSQL ¶
func (b *InsertBuilder) ToSQL() (string, []interface{}, error)
ToSQL generates the SQL query and arguments
func (*InsertBuilder) Values ¶
func (b *InsertBuilder) Values(data interface{}) *InsertBuilder
Values adds values to insert (can be called multiple times for batch insert)
type JoinClause ¶
type JoinClause struct {
Type string // "INNER", "LEFT", "RIGHT", "FULL"
Table interface{}
Condition expr.Expr
}
JoinClause represents a JOIN operation
type OrderByClause ¶
OrderByClause represents an ORDER BY clause
type SelectBuilder ¶
type SelectBuilder struct {
// contains filtered or unexported fields
}
SelectBuilder builds SELECT queries
func NewSelect ¶
func NewSelect(session SessionInterface, table interface{}) *SelectBuilder
NewSelect creates a new SELECT builder
func (*SelectBuilder) All ¶
func (b *SelectBuilder) All(dest interface{}) error
All executes the query and returns all results
func (*SelectBuilder) Count ¶
func (b *SelectBuilder) Count() (int64, error)
Count returns the count of matching rows
func (*SelectBuilder) Distinct ¶
func (b *SelectBuilder) Distinct() *SelectBuilder
Distinct enables DISTINCT
func (*SelectBuilder) GroupBy ¶
func (b *SelectBuilder) GroupBy(columns ...string) *SelectBuilder
GroupBy adds a GROUP BY clause
func (*SelectBuilder) Having ¶
func (b *SelectBuilder) Having(condition expr.Expr) *SelectBuilder
Having adds a HAVING condition
func (*SelectBuilder) Join ¶
func (b *SelectBuilder) Join(table interface{}, condition expr.Expr) *SelectBuilder
Join adds an INNER JOIN
func (*SelectBuilder) LeftJoin ¶
func (b *SelectBuilder) LeftJoin(table interface{}, condition expr.Expr) *SelectBuilder
LeftJoin adds a LEFT JOIN
func (*SelectBuilder) Limit ¶
func (b *SelectBuilder) Limit(limit int) *SelectBuilder
Limit sets the LIMIT
func (*SelectBuilder) Offset ¶
func (b *SelectBuilder) Offset(offset int) *SelectBuilder
Offset sets the OFFSET
func (*SelectBuilder) One ¶
func (b *SelectBuilder) One(dest interface{}) error
One executes the query and returns a single result
func (*SelectBuilder) OrderBy ¶
func (b *SelectBuilder) OrderBy(column string) *SelectBuilder
OrderBy adds an ORDER BY clause (default ASC)
func (*SelectBuilder) OrderByDesc ¶
func (b *SelectBuilder) OrderByDesc(column string) *SelectBuilder
OrderByDesc adds an ORDER BY DESC clause
func (*SelectBuilder) RightJoin ¶
func (b *SelectBuilder) RightJoin(table interface{}, condition expr.Expr) *SelectBuilder
RightJoin adds a RIGHT JOIN
func (*SelectBuilder) Select ¶
func (b *SelectBuilder) Select(columns ...string) *SelectBuilder
Select specifies which columns to select (defaults to all)
func (*SelectBuilder) ToSQL ¶
func (b *SelectBuilder) ToSQL() (string, []interface{}, error)
ToSQL generates the SQL query and arguments
func (*SelectBuilder) Where ¶
func (b *SelectBuilder) Where(condition expr.Expr) *SelectBuilder
Where adds a WHERE condition
type SessionInterface ¶
type SessionInterface interface {
Engine() *engine.Engine
Exec(query string, args ...interface{}) (sql.Result, error)
QueryRow(query string, args ...interface{}) *sql.Row
QueryRows(query string, args ...interface{}) (*sql.Rows, error)
GetTableName(tbl interface{}) string
GetTableColumns(tbl interface{}) []*table.ColumnRef
}
SessionInterface defines the methods required by query builders
type UpdateBuilder ¶
type UpdateBuilder struct {
// contains filtered or unexported fields
}
UpdateBuilder builds UPDATE queries
func NewUpdate ¶
func NewUpdate(session SessionInterface, table interface{}) *UpdateBuilder
NewUpdate creates a new UPDATE builder
func (*UpdateBuilder) Exec ¶
func (b *UpdateBuilder) Exec() (interface{}, error)
Exec executes the UPDATE and returns the result
func (*UpdateBuilder) One ¶
func (b *UpdateBuilder) One(dest interface{}) error
One executes the UPDATE with RETURNING and scans into dest
func (*UpdateBuilder) Returning ¶
func (b *UpdateBuilder) Returning(columns ...string) *UpdateBuilder
Returning specifies which columns to return
func (*UpdateBuilder) Set ¶
func (b *UpdateBuilder) Set(column string, value interface{}) *UpdateBuilder
Set sets a column value
func (*UpdateBuilder) ToSQL ¶
func (b *UpdateBuilder) ToSQL() (string, []interface{}, error)
ToSQL generates the SQL query and arguments
func (*UpdateBuilder) Where ¶
func (b *UpdateBuilder) Where(condition expr.Expr) *UpdateBuilder
Where adds a WHERE condition