Documentation ¶
Index ¶
- Constants
- func DeleteFrom(table string) *stmt.Delete
- func InsertInto(table, fields string) *stmt.Insert
- func IsErrDuplicate(e error) bool
- func IsErrNotFound(e error) bool
- func Register(name string, driver Driver)
- func Select(fields string) *stmt.SelectFields
- func Update(table string) *stmt.Update
- type Config
- type Connection
- func (c *Connection) Begin() (*Tx, error)
- func (c *Connection) Close() error
- func (c *Connection) Connect(opts ...Options) error
- func (c *Connection) Driver() Driver
- func (c *Connection) EnumValues(field string) ([]string, error)
- func (c *Connection) Exec(query string, args ...interface{}) (*Result, error)
- func (c *Connection) Get(query string, args ...interface{}) (Resultset, error)
- func (c *Connection) GetStruct(dest interface{}, query string, args ...interface{}) error
- func (c *Connection) Insert(tableName string, dataMap map[string]interface{}) (*Result, error)
- func (c *Connection) MustBegin() *Tx
- func (c *Connection) MustExec(query string, args ...interface{}) *Result
- func (c *Connection) MustGet(query string, args ...interface{}) Resultset
- func (c *Connection) MustInsert(tableName string, dataMap map[string]interface{}) *Result
- func (c *Connection) MustSelect(query string, args ...interface{}) []Resultset
- func (c *Connection) Ping() error
- func (c *Connection) Query(query string, args ...interface{}) (*Rows, error)
- func (c *Connection) SQL(stmt interface{}) string
- func (c *Connection) Select(query string, args ...interface{}) ([]Resultset, error)
- func (c *Connection) SelectStruct(dest interface{}, query string, args ...interface{}) error
- func (c *Connection) SetConnMaxLifetime(duration time.Duration)
- func (c *Connection) SetMaxIdleConns(max int)
- func (c *Connection) SetMaxOpenConns(max int)
- type Driver
- type Error
- type Options
- type Result
- type Resultset
- func (r Resultset) Bool(name string) bool
- func (r Resultset) BoolNil(name string) *bool
- func (r Resultset) Bytes(name string) []byte
- func (r Resultset) Float(name string) float64
- func (r Resultset) FloatNil(name string) *float64
- func (r Resultset) FloatOr(name string, defValue float64) float64
- func (r Resultset) Int(name string) int
- func (r Resultset) IntNil(name string) *int
- func (r Resultset) IntOr(name string, defValue int) int
- func (r Resultset) Interface(name string) interface{}
- func (r Resultset) String(name string) string
- func (r Resultset) StringNil(name string) *string
- func (r Resultset) StringOr(name string, defValue string) string
- func (r Resultset) Time(name string) time.Time
- func (r Resultset) TimeNil(name string) *time.Time
- type Rows
- type SQLStatement
- type Tx
- func (t *Tx) Commit() error
- func (t *Tx) Exec(query string, args ...interface{}) (*Result, error)
- func (t *Tx) Get(query string, args ...interface{}) (Resultset, error)
- func (t *Tx) GetStruct(dest interface{}, query string, args ...interface{}) error
- func (t *Tx) Insert(tableName string, dataMap map[string]interface{}) (*Result, error)
- func (t *Tx) MustExec(query string, args ...interface{}) *Result
- func (t *Tx) MustGet(query string, args ...interface{}) Resultset
- func (t *Tx) MustInsert(tableName string, dataMap map[string]interface{}) *Result
- func (t *Tx) MustRecover()
- func (t *Tx) MustSelect(query string, args ...interface{}) []Resultset
- func (t *Tx) Recover()
- func (t *Tx) Rollback() error
- func (t *Tx) Select(query string, args ...interface{}) ([]Resultset, error)
- func (t *Tx) SelectStruct(dest interface{}, query string, args ...interface{}) error
Constants ¶
View Source
const ( DriverMySQL = `mysql` DriverSQLServer = `sqlserver` )
View Source
const ( ErrConnectionNotFound = Error(`connection not found`) ErrDriverNotDefined = Error(`database driver not defined`) )
Variables ¶
This section is empty.
Functions ¶
func DeleteFrom ¶ added in v0.16.0
func InsertInto ¶
func IsErrDuplicate ¶ added in v0.12.0
func IsErrNotFound ¶ added in v0.12.2
func Select ¶
func Select(fields string) *stmt.SelectFields
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection ...
func (*Connection) Driver ¶
func (c *Connection) Driver() Driver
func (*Connection) EnumValues ¶
func (c *Connection) EnumValues(field string) ([]string, error)
EnumValues return enum values, parameter field using dot notation. Ex: profile.gender , returning ['male', 'female']
func (*Connection) Exec ¶
func (c *Connection) Exec(query string, args ...interface{}) (*Result, error)
Exec ...
func (*Connection) Get ¶
func (c *Connection) Get(query string, args ...interface{}) (Resultset, error)
Get ...
func (*Connection) GetStruct ¶
func (c *Connection) GetStruct(dest interface{}, query string, args ...interface{}) error
GetStruct ...
func (*Connection) Insert ¶
func (c *Connection) Insert(tableName string, dataMap map[string]interface{}) (*Result, error)
Insert ...
func (*Connection) MustExec ¶
func (c *Connection) MustExec(query string, args ...interface{}) *Result
MustExec ...
func (*Connection) MustGet ¶
func (c *Connection) MustGet(query string, args ...interface{}) Resultset
MustGet ...
func (*Connection) MustInsert ¶
func (c *Connection) MustInsert(tableName string, dataMap map[string]interface{}) *Result
MustInsert ...
func (*Connection) MustSelect ¶
func (c *Connection) MustSelect(query string, args ...interface{}) []Resultset
MustSelect ...
func (*Connection) Query ¶ added in v0.10.3
func (c *Connection) Query(query string, args ...interface{}) (*Rows, error)
func (*Connection) SQL ¶ added in v0.15.1
func (c *Connection) SQL(stmt interface{}) string
func (*Connection) Select ¶
func (c *Connection) Select(query string, args ...interface{}) ([]Resultset, error)
Select ...
func (*Connection) SelectStruct ¶
func (c *Connection) SelectStruct(dest interface{}, query string, args ...interface{}) error
SelectStruct ...
func (*Connection) SetConnMaxLifetime ¶
func (c *Connection) SetConnMaxLifetime(duration time.Duration)
SetConnMaxLifetime ...
func (*Connection) SetMaxIdleConns ¶
func (c *Connection) SetMaxIdleConns(max int)
SetMaxIdleConns ...
func (*Connection) SetMaxOpenConns ¶
func (c *Connection) SetMaxOpenConns(max int)
SetMaxOpenConns ...
type Options ¶ added in v0.14.0
type Options func(*Connection)
func OptionDisableEncryption ¶ added in v0.14.0
func OptionDisableEncryption() Options
func OptionMaxIdle ¶ added in v0.14.0
OptionMaxIdle default is 2
func OptionMaxIdleTime ¶ added in v0.14.0
OptionMaxIdleTime default is 60 seconds
func OptionMaxLifetime ¶ added in v0.14.0
OptionMaxLifetime default is 5 minutes
func OptionMaxOpen ¶ added in v0.14.0
OptionMaxOpen default is 0 (unlimited)
type Resultset ¶
type Resultset map[string]interface{}
Resultset ...
type SQLStatement ¶ added in v0.10.2
type SQLStatement struct {
// contains filtered or unexported fields
}
func SQL ¶ added in v0.10.2
func SQL(statement string) SQLStatement
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
func (*Tx) MustInsert ¶
func (*Tx) MustRecover ¶
func (t *Tx) MustRecover()
func (*Tx) MustSelect ¶
func (*Tx) SelectStruct ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.