Documentation
¶
Index ¶
- Variables
- type DBMS
- type InsertStatement
- func (s InsertStatement) Build() (query string, args []interface{}, dest []interface{})
- func (s InsertStatement) Into(table string) InsertStatement
- func (s InsertStatement) Return(col string, dest interface{}) InsertStatement
- func (s InsertStatement) ReturnSQL(sql string, dest interface{}) InsertStatement
- func (s InsertStatement) Set(col string, val interface{}) InsertStatement
- func (s InsertStatement) SetSQL(col, sql string) InsertStatement
- type SelectStatement
- func (s SelectStatement) Build() (query string, args []interface{}, dest []interface{})
- func (s SelectStatement) From(table string) SelectStatement
- func (s SelectStatement) Group(group string) SelectStatement
- func (s SelectStatement) Having(having string) SelectStatement
- func (s SelectStatement) Join(sql string, args ...interface{}) SelectStatement
- func (s SelectStatement) Limit(limit int) SelectStatement
- func (s SelectStatement) Lock() SelectStatement
- func (s SelectStatement) Map(col string, dest interface{}) SelectStatement
- func (s SelectStatement) MapSQL(col string, dest interface{}) SelectStatement
- func (s SelectStatement) Offset(offset int) SelectStatement
- func (s SelectStatement) Order(order string) SelectStatement
- func (s SelectStatement) Where(cond string, args ...interface{}) SelectStatement
- type UpdateStatement
- func (s UpdateStatement) Build() (query string, args []interface{})
- func (s UpdateStatement) Set(col string, val interface{}) UpdateStatement
- func (s UpdateStatement) SetSQL(col string, sql string) UpdateStatement
- func (s UpdateStatement) Table(table string) UpdateStatement
- func (s UpdateStatement) Where(cond string, args ...interface{}) UpdateStatement
Constants ¶
This section is empty.
Variables ¶
var ( MySQL = DBMS{/* contains filtered or unexported fields */} Postgres = DBMS{/* contains filtered or unexported fields */} )
var DefaultDBMS = MySQL
DefaultDBMS is the DBMS used by the package-level Select, Insert, and Update functions.
Functions ¶
This section is empty.
Types ¶
type DBMS ¶
type DBMS struct {
// contains filtered or unexported fields
}
DBMS represents a DBMS.
func (DBMS) Insert ¶
func (dbms DBMS) Insert() InsertStatement
Insert returns a new INSERT statement.
func (DBMS) Placeholder ¶
Placeholder returns the placeholder string for the given index.
func (DBMS) Select ¶
func (dbms DBMS) Select() SelectStatement
Select returns a new SELECT statement.
func (DBMS) Update ¶
func (dbms DBMS) Update() UpdateStatement
Update returns a new UPDATE statement.
type InsertStatement ¶
type InsertStatement struct {
// contains filtered or unexported fields
}
InsertStatement represents an INSERT statement.
func Insert ¶
func Insert() InsertStatement
Insert returns a new INSERT statement using the default DBMS.
func (InsertStatement) Build ¶
func (s InsertStatement) Build() (query string, args []interface{}, dest []interface{})
Build builds the SQL query. It returns the SQL query and the argument slice.
func (InsertStatement) Into ¶
func (s InsertStatement) Into(table string) InsertStatement
Into returns a new statement with the table to insert into set to 'table'.
func (InsertStatement) Return ¶
func (s InsertStatement) Return(col string, dest interface{}) InsertStatement
Return returns a new statement with a RETURNING clause.
func (InsertStatement) ReturnSQL ¶
func (s InsertStatement) ReturnSQL(sql string, dest interface{}) InsertStatement
ReturnSQL is Return without quoting the argument.
func (InsertStatement) Set ¶
func (s InsertStatement) Set(col string, val interface{}) InsertStatement
Set returns a new statement with column 'col' set to value 'val'.
func (InsertStatement) SetSQL ¶
func (s InsertStatement) SetSQL(col, sql string) InsertStatement
SetSQL returns a new statement with column 'col' set to the raw SQL expression 'sql'.
type SelectStatement ¶
type SelectStatement struct {
// contains filtered or unexported fields
}
SelectStatement represents a SELECT statement.
func Select ¶
func Select() SelectStatement
Select returns a new SELECT statement using the default DBMS.
func (SelectStatement) Build ¶
func (s SelectStatement) Build() (query string, args []interface{}, dest []interface{})
Build builds the SQL query. It returns the query, the argument slice, and the destination slice.
func (SelectStatement) From ¶
func (s SelectStatement) From(table string) SelectStatement
From returns a new statement with the table to select from set to 'table'.
func (SelectStatement) Group ¶
func (s SelectStatement) Group(group string) SelectStatement
Group returns a new statement with grouping 'group'. Only the last Group() is used.
func (SelectStatement) Having ¶
func (s SelectStatement) Having(having string) SelectStatement
Having returns a new statement with HAVING condition 'having'. Only the last Having() is used.
func (SelectStatement) Join ¶
func (s SelectStatement) Join(sql string, args ...interface{}) SelectStatement
Join returns a new statement with JOIN expression 'sql'.
func (SelectStatement) Limit ¶
func (s SelectStatement) Limit(limit int) SelectStatement
Limit returns a new statement with the limit set to 'limit'.
func (SelectStatement) Lock ¶
func (s SelectStatement) Lock() SelectStatement
Lock returns a new statement with FOR UPDATE locking.
func (SelectStatement) Map ¶
func (s SelectStatement) Map(col string, dest interface{}) SelectStatement
Map returns a new statement with column 'col' selected and scanned into 'dest'. 'dest' may be nil if the value should not be scanned.
func (SelectStatement) MapSQL ¶
func (s SelectStatement) MapSQL(col string, dest interface{}) SelectStatement
MapSQL is Map without quoting col.
func (SelectStatement) Offset ¶
func (s SelectStatement) Offset(offset int) SelectStatement
Offset returns a new statement with the offset set to 'offset'.
func (SelectStatement) Order ¶
func (s SelectStatement) Order(order string) SelectStatement
Order returns a new statement with ordering 'order'. Only the last Order() is used.
func (SelectStatement) Where ¶
func (s SelectStatement) Where(cond string, args ...interface{}) SelectStatement
Where returns a new statement with condition 'cond'. Multiple conditions are combined with AND.
type UpdateStatement ¶
type UpdateStatement struct {
// contains filtered or unexported fields
}
UpdateStatement represents an UPDATE statement.
func Update ¶
func Update() UpdateStatement
Update returns a new UPDATE statement using the default DBMS.
func (UpdateStatement) Build ¶
func (s UpdateStatement) Build() (query string, args []interface{})
Build builds the SQL query. It returns the query and the argument slice.
func (UpdateStatement) Set ¶
func (s UpdateStatement) Set(col string, val interface{}) UpdateStatement
Set returns a new statement with column 'col' set to value 'val'.
func (UpdateStatement) SetSQL ¶
func (s UpdateStatement) SetSQL(col string, sql string) UpdateStatement
SetSQL returns a new statement with column 'col' set to SQL expression 'sql'.
func (UpdateStatement) Table ¶
func (s UpdateStatement) Table(table string) UpdateStatement
Table returns a new statement with the table to update set to 'table'.
func (UpdateStatement) Where ¶
func (s UpdateStatement) Where(cond string, args ...interface{}) UpdateStatement
Where returns a new statement with condition 'cond'. Multiple Where() are combined with AND.