Documentation
¶
Index ¶
- func Init(option IOption)
- func NewStack() *stack
- func PB(b bool) *bool
- func PF64(f float64) *float64
- func PI64(i int64) *int64
- func PS(s string) *string
- func PT(t time.Time) *time.Time
- func Parse(r io.Reader) *node
- func RowBounds(offset int, limit int) *rowBounds
- func SetLogger(log ILogger)
- type DB
- func (d *DB) Begin() (*sql.Tx, error)
- func (d *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
- func (g *DB) Close() error
- func (g *DB) Delete(stmt string, param interface{}) (int64, error)
- func (g *DB) DeleteContext(ctx context.Context, stmt string, param interface{}) (int64, error)
- func (g *DB) Insert(stmt string, param interface{}) (int64, int64, error)
- func (g *DB) InsertBatch(stmt string, param interface{}) (int64, int64, error)
- func (g *DB) InsertContext(ctx context.Context, stmt string, param interface{}) (int64, int64, error)
- func (g *DB) Select(stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error)
- func (g *DB) SelectContext(ctx context.Context, stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error)
- func (g *DB) SelectV2(stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error)
- func (d *DB) Transaction(fn func(tx *sql.Tx) error) error
- func (d *DB) TransactionTX(ctx context.Context, opts *sql.TxOptions, fn func(tx *sql.Tx) error) error
- func (g *DB) Update(stmt string, param interface{}) (int64, error)
- func (g *DB) UpdateContext(ctx context.Context, stmt string, param interface{}) (int64, error)
- type DBConfig
- type DBConfigBuilder
- func (d *DBConfigBuilder) Build() *DBConfig
- func (d *DBConfigBuilder) DB(db map[string]*GoBatisDB) *DBConfigBuilder
- func (d *DBConfigBuilder) DS(dss []*DataSource) *DBConfigBuilder
- func (d *DBConfigBuilder) Mappers(mappers []string) *DBConfigBuilder
- func (d *DBConfigBuilder) ShowSQL(showSQL bool) *DBConfigBuilder
- type DBOption
- type DBType
- type DSOption
- type DataSource
- type DataSourceBuilder
- func (d *DataSourceBuilder) Build() *DataSource
- func (d *DataSourceBuilder) DataSource(ds string) *DataSourceBuilder
- func (d *DataSourceBuilder) DataSourceName(dsn string) *DataSourceBuilder
- func (d *DataSourceBuilder) DriverName(dn string) *DataSourceBuilder
- func (d *DataSourceBuilder) MaxIdleConns(mic int) *DataSourceBuilder
- func (d *DataSourceBuilder) MaxLifeTime(mlt int) *DataSourceBuilder
- func (d *DataSourceBuilder) MaxOpenConns(moc int) *DataSourceBuilder
- type ElemType
- type FileOption
- type GoBatis
- type GoBatisDB
- type ILogger
- type IOption
- type LogLevel
- type NullBool
- type NullFloat64
- type NullInt64
- type NullString
- type NullTime
- type OptionType
- type OutType
- type ResultType
- type TX
- func (g *TX) Close() error
- func (g *TX) Delete(stmt string, param interface{}) (int64, error)
- func (g *TX) DeleteContext(ctx context.Context, stmt string, param interface{}) (int64, error)
- func (g *TX) Insert(stmt string, param interface{}) (int64, int64, error)
- func (g *TX) InsertBatch(stmt string, param interface{}) (int64, int64, error)
- func (g *TX) InsertContext(ctx context.Context, stmt string, param interface{}) (int64, int64, error)
- func (g *TX) Select(stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error)
- func (g *TX) SelectContext(ctx context.Context, stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error)
- func (g *TX) SelectV2(stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error)
- func (g *TX) Update(stmt string, param interface{}) (int64, error)
- func (g *TX) UpdateContext(ctx context.Context, stmt string, param interface{}) (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB
func (*DB) DeleteContext ¶
func (*DB) InsertBatch ¶
func (*DB) InsertContext ¶
func (*DB) Select ¶
func (g *DB) Select(stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error)
reference from https://github.com/yinshuwei/osm/blob/master/osm.go end
func (*DB) SelectContext ¶
func (*DB) TransactionTX ¶
func (d *DB) TransactionTX(ctx context.Context, opts *sql.TxOptions, fn func(tx *sql.Tx) error) error
Transaction tx
type DBConfig ¶
type DBConfig struct {
DB []*DataSource `yaml:"db"`
ShowSQL bool `yaml:"showSQL"`
Mappers []string `yaml:"mappers"`
// contains filtered or unexported fields
}
type DBConfigBuilder ¶
type DBConfigBuilder struct {
// contains filtered or unexported fields
}
func NewDBConfigBuilder ¶
func NewDBConfigBuilder() *DBConfigBuilder
func (*DBConfigBuilder) Build ¶
func (d *DBConfigBuilder) Build() *DBConfig
func (*DBConfigBuilder) DB ¶
func (d *DBConfigBuilder) DB(db map[string]*GoBatisDB) *DBConfigBuilder
func (*DBConfigBuilder) DS ¶
func (d *DBConfigBuilder) DS(dss []*DataSource) *DBConfigBuilder
func (*DBConfigBuilder) Mappers ¶
func (d *DBConfigBuilder) Mappers(mappers []string) *DBConfigBuilder
func (*DBConfigBuilder) ShowSQL ¶
func (d *DBConfigBuilder) ShowSQL(showSQL bool) *DBConfigBuilder
type DBOption ¶
type DBOption struct {
// contains filtered or unexported fields
}
func NewDBOption ¶
func NewDBOption() *DBOption
func NewDBOption_ ¶
func (*DBOption) Type ¶
func (ds *DBOption) Type() OptionType
type DSOption ¶
type DSOption struct {
// contains filtered or unexported fields
}
func NewDSOption ¶
func NewDSOption() *DSOption
func NewDSOption_ ¶
func NewDSOption_(dss []*DataSource, showSQL bool, mappers []string) *DSOption
func (*DSOption) DS ¶
func (ds *DSOption) DS(dss []*DataSource) *DSOption
func (*DSOption) Type ¶
func (ds *DSOption) Type() OptionType
type DataSource ¶
type DataSource struct {
DataSource string `yaml:"datasource"`
DriverName string `yaml:"driverName"`
DataSourceName string `yaml:"dataSourceName"`
MaxLifeTime int `yaml:"maxLifeTime"`
MaxOpenConns int `yaml:"maxOpenConns"`
MaxIdleConns int `yaml:"maxIdleConns"`
}
func NewDataSource ¶
func NewDataSource(dataSource string, driverName string, dataSourceName string) *DataSource
NewDataSource new data source
func NewDataSource_ ¶
func NewDataSource_(dataSource string, driverName string, dataSourceName string, maxLifeTime int, maxOpenConns int, maxIdleConns int) *DataSource
NewDataSource_ new data source
type DataSourceBuilder ¶
type DataSourceBuilder struct {
// contains filtered or unexported fields
}
func NewDataSourceBuilder ¶
func NewDataSourceBuilder() *DataSourceBuilder
func (*DataSourceBuilder) Build ¶
func (d *DataSourceBuilder) Build() *DataSource
func (*DataSourceBuilder) DataSource ¶
func (d *DataSourceBuilder) DataSource(ds string) *DataSourceBuilder
DataSource
func (*DataSourceBuilder) DataSourceName ¶
func (d *DataSourceBuilder) DataSourceName(dsn string) *DataSourceBuilder
DataSourceName
func (*DataSourceBuilder) DriverName ¶
func (d *DataSourceBuilder) DriverName(dn string) *DataSourceBuilder
DriverName
func (*DataSourceBuilder) MaxIdleConns ¶
func (d *DataSourceBuilder) MaxIdleConns(mic int) *DataSourceBuilder
MaxIdleConns
func (*DataSourceBuilder) MaxLifeTime ¶
func (d *DataSourceBuilder) MaxLifeTime(mlt int) *DataSourceBuilder
MaxLifeTime
func (*DataSourceBuilder) MaxOpenConns ¶
func (d *DataSourceBuilder) MaxOpenConns(moc int) *DataSourceBuilder
MaxOpenConns
type FileOption ¶
type FileOption struct {
// contains filtered or unexported fields
}
func NewFileOption ¶
func NewFileOption(pt ...string) *FileOption
NewFileOption db config file path, default: db.yml
func (*FileOption) ToDBConf ¶
func (f *FileOption) ToDBConf() *DBConfig
func (*FileOption) Type ¶
func (f *FileOption) Type() OptionType
type GoBatis ¶
type GoBatis interface {
// Select 查询数据
Select(stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error)
// SelectContext 查询数据with context
SelectContext(ctx context.Context, stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error)
// Insert 插入数据
Insert(stmt string, param interface{}) (lastInsertId int64, affected int64, err error)
// InsertContext 插入数据with context
InsertContext(ctx context.Context, stmt string, param interface{}) (lastInsertId int64, affected int64, err error)
// Update 更新数据
Update(stmt string, param interface{}) (affected int64, err error)
// UpdateContext 更新数据with context
UpdateContext(ctx context.Context, stmt string, param interface{}) (affected int64, err error)
// Delete 刪除数据
Delete(stmt string, param interface{}) (affected int64, err error)
// DeleteContext 刪除数据with context
DeleteContext(ctx context.Context, stmt string, param interface{}) (affected int64, err error)
}
type ILogger ¶
type ILogger interface {
SetLevel(level LogLevel)
Info(format string, v ...interface{})
Debug(format string, v ...interface{})
Warn(format string, v ...interface{})
Error(format string, v ...interface{})
Fatal(format string, v ...interface{})
}
如果想定制logger可以实现此接口,否则日志将使用默认打印
var LOG ILogger = defLog
type IOption ¶
type IOption interface {
Type() OptionType
ToDBConf() *DBConfig
}
type NullFloat64 ¶
type NullFloat64 = sql.NullFloat64
type NullString ¶
type NullString = sql.NullString
type OptionType ¶
type OptionType int
const ( OptionTypeFile OptionType = 1 OptionTypeDS OptionType = 2 OptionTypeDB OptionType = 3 )
type ResultType ¶
type ResultType string
func GetResultType ¶
func GetResultType(res interface{}) ResultType
type TX ¶
type TX struct {
// contains filtered or unexported fields
}
TX
func (*TX) DeleteContext ¶
func (*TX) InsertBatch ¶
func (*TX) InsertContext ¶
func (*TX) Select ¶
func (g *TX) Select(stmt string, param interface{}, rowBound ...*rowBounds) func(res interface{}) (int64, error)
reference from https://github.com/yinshuwei/osm/blob/master/osm.go end
func (*TX) SelectContext ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.