Documentation ¶
Index ¶
- Constants
- func SetLogger(logger func(string))
- type Column
- type Database
- func (this *Database) Begin() (*Transaction, error)
- func (this *Database) Close()
- func (this *Database) CreateTable(name string) error
- func (this *Database) CreateTables() error
- func (this *Database) DB() *sql.DB
- func (this *Database) DriverName() string
- func (this *Database) DropTable(name string) error
- func (this *Database) GetTableSchema(name string) (Table, error)
- func (this *Database) Open(driver, dsn string) error
- func (this *Database) OpenMySQL(dbName, user, passwd, host string, port int) error
- func (this *Database) OpenSQLite(dbFile string) error
- func (this *Database) RegisterTable(name string, table interface{}) error
- func (this *Database) T(name string) *SQLExecutor
- type SQLExecutor
- func (this *SQLExecutor) Count(where string, args ...interface{}) (int, error)
- func (this *SQLExecutor) CountAll() (int, error)
- func (this *SQLExecutor) Delete(where string, args ...interface{}) error
- func (this *SQLExecutor) Insert(row interface{}) (sql.Result, error)
- func (this *SQLExecutor) Replace(row interface{}) (sql.Result, error)
- func (this *SQLExecutor) Select(cols ...string) *SQLSelector
- func (this *SQLExecutor) SelectAll() *SQLSelector
- func (this *SQLExecutor) Update(where string, args ...interface{}) *SQLUpdater
- type SQLJointer
- func (this *SQLJointer) All(rows ...interface{}) error
- func (this *SQLJointer) Asc(cols ...string) *SQLJointer
- func (this *SQLJointer) Desc(cols ...string) *SQLJointer
- func (this *SQLJointer) Filter(where string, args ...interface{}) *SQLJointer
- func (this *SQLJointer) FullJoin(table, onLeft, onRight string) jointer
- func (this *SQLJointer) FullOuterJoin(table, onLeft, onRight string) jointer
- func (this *SQLJointer) InnerJoin(table, onLeft, onRight string) jointer
- func (this *SQLJointer) LeftJoin(table, onLeft, onRight, onWhere string) jointer
- func (this *SQLJointer) LeftOuterJoin(table, onLeft, onRight string) jointer
- func (this *SQLJointer) Limit(n int) *SQLJointer
- func (this *SQLJointer) Offset(n int) *SQLJointer
- func (this *SQLJointer) One(rows ...interface{}) error
- func (this *SQLJointer) RightJoin(table, onLeft, onRight, onWhere string) jointer
- func (this *SQLJointer) RightOuterJoin(table, onLeft, onRight string) jointer
- func (this *SQLJointer) Run() (*sql.Rows, error)
- type SQLSelector
- func (this *SQLSelector) All(rows interface{}) error
- func (this *SQLSelector) Asc(cols ...string) *SQLSelector
- func (this *SQLSelector) Desc(cols ...string) *SQLSelector
- func (this *SQLSelector) Filter(where string, args ...interface{}) *SQLSelector
- func (this *SQLSelector) FullJoin(table, onLeft, onRight string) jointer
- func (this *SQLSelector) FullOuterJoin(table, onLeft, onRight string) jointer
- func (this *SQLSelector) InnerJoin(table, onLeft, onRight string) jointer
- func (this *SQLSelector) LeftJoin(table, onLeft, onRight string) jointer
- func (this *SQLSelector) LeftOuterJoin(table, onLeft, onRight string) jointer
- func (this *SQLSelector) Limit(n int) *SQLSelector
- func (this *SQLSelector) Offset(n int) *SQLSelector
- func (this *SQLSelector) One(row interface{}) error
- func (this *SQLSelector) RightJoin(table, onLeft, onRight string) jointer
- func (this *SQLSelector) RightOuterJoin(table, onLeft, onRight string) jointer
- func (this *SQLSelector) Run() (*sql.Rows, error)
- func (this *SQLSelector) Values(values ...interface{}) error
- type SQLUpdater
- type Table
- func (this *Table) ColumnIndexes() []int
- func (this *Table) ColumnNames() []string
- func (this *Table) CreateSQL(driver string) (string, error)
- func (this *Table) GetColumnsFromForm(r *http.Request) ([]string, []interface{}, error)
- func (this *Table) GetColumnsMapFromForm(r *http.Request) (map[string]interface{}, error)
- func (this *Table) Parse(name string, table interface{}) error
- type Transaction
Constants ¶
const ( DRIVER_SQLITE3 = "sqlite3" DRIVER_MYSQL = "mysql" DRIVER_POSTGRE = "postgre" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func NewDatabase ¶
func NewDatabase() *Database
func (*Database) Begin ¶
func (this *Database) Begin() (*Transaction, error)
func (*Database) CreateTable ¶
func (*Database) CreateTables ¶
func (*Database) DriverName ¶
func (*Database) GetTableSchema ¶ added in v0.1.3
func (*Database) OpenSQLite ¶
func (*Database) RegisterTable ¶
func (*Database) T ¶
func (this *Database) T(name string) *SQLExecutor
type SQLExecutor ¶
type SQLExecutor struct {
// contains filtered or unexported fields
}
SQLExecutor
func (*SQLExecutor) Count ¶
func (this *SQLExecutor) Count(where string, args ...interface{}) (int, error)
Count counts rows by given filter
func (*SQLExecutor) CountAll ¶
func (this *SQLExecutor) CountAll() (int, error)
CountAll counts all rows of table
func (*SQLExecutor) Delete ¶
func (this *SQLExecutor) Delete(where string, args ...interface{}) error
Delete deletes rows by given filter
func (*SQLExecutor) Insert ¶
func (this *SQLExecutor) Insert(row interface{}) (sql.Result, error)
Insert inserts given row to table
func (*SQLExecutor) Replace ¶
func (this *SQLExecutor) Replace(row interface{}) (sql.Result, error)
Replace replaces with given row
func (*SQLExecutor) Select ¶
func (this *SQLExecutor) Select(cols ...string) *SQLSelector
Select selects the given columns from table
func (*SQLExecutor) SelectAll ¶
func (this *SQLExecutor) SelectAll() *SQLSelector
SelectAll selects all columns from table
func (*SQLExecutor) Update ¶
func (this *SQLExecutor) Update(where string, args ...interface{}) *SQLUpdater
Update updates row by given filter
type SQLJointer ¶
type SQLJointer struct {
// contains filtered or unexported fields
}
func (*SQLJointer) All ¶
func (this *SQLJointer) All(rows ...interface{}) error
func (*SQLJointer) Asc ¶
func (this *SQLJointer) Asc(cols ...string) *SQLJointer
Asc sorts given columns by asc
func (*SQLJointer) Desc ¶
func (this *SQLJointer) Desc(cols ...string) *SQLJointer
Desc sorts given columns by desc
func (*SQLJointer) Filter ¶
func (this *SQLJointer) Filter(where string, args ...interface{}) *SQLJointer
Filter set filters for select
func (*SQLJointer) FullJoin ¶
func (this *SQLJointer) FullJoin(table, onLeft, onRight string) jointer
func (*SQLJointer) FullOuterJoin ¶
func (this *SQLJointer) FullOuterJoin(table, onLeft, onRight string) jointer
func (*SQLJointer) InnerJoin ¶
func (this *SQLJointer) InnerJoin(table, onLeft, onRight string) jointer
func (*SQLJointer) LeftJoin ¶
func (this *SQLJointer) LeftJoin( table, onLeft, onRight, onWhere string, ) jointer
func (*SQLJointer) LeftOuterJoin ¶
func (this *SQLJointer) LeftOuterJoin(table, onLeft, onRight string) jointer
func (*SQLJointer) Limit ¶
func (this *SQLJointer) Limit(n int) *SQLJointer
Limit sets limit of query
func (*SQLJointer) Offset ¶
func (this *SQLJointer) Offset(n int) *SQLJointer
Offset sets offset of query
func (*SQLJointer) One ¶
func (this *SQLJointer) One(rows ...interface{}) error
func (*SQLJointer) RightJoin ¶
func (this *SQLJointer) RightJoin( table, onLeft, onRight, onWhere string, ) jointer
func (*SQLJointer) RightOuterJoin ¶
func (this *SQLJointer) RightOuterJoin(table, onLeft, onRight string) jointer
type SQLSelector ¶
type SQLSelector struct {
// contains filtered or unexported fields
}
SQLSelector
func (*SQLSelector) All ¶
func (this *SQLSelector) All(rows interface{}) error
All selects all rows from table
func (*SQLSelector) Asc ¶
func (this *SQLSelector) Asc(cols ...string) *SQLSelector
Asc sorts given columns by asc
func (*SQLSelector) Desc ¶
func (this *SQLSelector) Desc(cols ...string) *SQLSelector
Desc sorts given columns by desc
func (*SQLSelector) Filter ¶
func (this *SQLSelector) Filter(where string, args ...interface{}) *SQLSelector
Filter set filters for select
func (*SQLSelector) FullJoin ¶
func (this *SQLSelector) FullJoin(table, onLeft, onRight string) jointer
func (*SQLSelector) FullOuterJoin ¶
func (this *SQLSelector) FullOuterJoin(table, onLeft, onRight string) jointer
func (*SQLSelector) InnerJoin ¶
func (this *SQLSelector) InnerJoin(table, onLeft, onRight string) jointer
func (*SQLSelector) LeftJoin ¶
func (this *SQLSelector) LeftJoin(table, onLeft, onRight string) jointer
func (*SQLSelector) LeftOuterJoin ¶
func (this *SQLSelector) LeftOuterJoin(table, onLeft, onRight string) jointer
func (*SQLSelector) Limit ¶
func (this *SQLSelector) Limit(n int) *SQLSelector
Limit sets limit of query
func (*SQLSelector) Offset ¶
func (this *SQLSelector) Offset(n int) *SQLSelector
Offset sets offset of query
func (*SQLSelector) One ¶
func (this *SQLSelector) One(row interface{}) error
One selects one row from table
func (*SQLSelector) RightJoin ¶
func (this *SQLSelector) RightJoin(table, onLeft, onRight string) jointer
func (*SQLSelector) RightOuterJoin ¶
func (this *SQLSelector) RightOuterJoin(table, onLeft, onRight string) jointer
func (*SQLSelector) Values ¶
func (this *SQLSelector) Values(values ...interface{}) error
One selects one row from table
type SQLUpdater ¶
type SQLUpdater struct {
// contains filtered or unexported fields
}
SQLUpdater
func (*SQLUpdater) Set ¶
func (this *SQLUpdater) Set(cols ...string) *SQLUpdater
Set sets columns to be updated
func (*SQLUpdater) Value ¶
func (this *SQLUpdater) Value(row interface{}) (sql.Result, error)
Value updates given row to table
type Table ¶
func (*Table) ColumnIndexes ¶
func (*Table) ColumnNames ¶
func (*Table) GetColumnsFromForm ¶ added in v0.1.2
func (*Table) GetColumnsMapFromForm ¶ added in v0.1.4
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Database Transaction
func (*Transaction) Commit ¶
func (this *Transaction) Commit() error
func (*Transaction) Rollback ¶
func (this *Transaction) Rollback() error
func (*Transaction) T ¶
func (this *Transaction) T(name string) *SQLExecutor
func (*Transaction) Tx ¶
func (this *Transaction) Tx() *sql.Tx