Documentation ¶
Index ¶
- Constants
- func CreateFactory(opts ...FacOpt) (factory.Factory, error)
- func DynamicParserFactory(sql string) (sqlparser.SqlParser, error)
- func FindDynamicSqlParser(sqlId string) (sqlparser.SqlParser, bool)
- func FindTemplateSqlParser(sqlId string) (sqlparser.SqlParser, bool)
- func NewFactory(opts ...FacOpt) factory.Factory
- func ParseObject(bean interface{}) (reflection.Object, error)
- func RegisterMapperData(data []byte) error
- func RegisterMapperFile(file string) error
- func RegisterModel(model interface{}) error
- func RegisterModelWithName(name string, model interface{}) error
- func RegisterSql(sqlId string, sql string) error
- func RegisterTemplateData(data []byte) error
- func RegisterTemplateFile(file string) error
- func ScanMapperFile(dir string) error
- func TemplateParserFactory(sql string) (sqlparser.SqlParser, error)
- func UnregisterSql(sqlId string)
- func WithSession(ctx context.Context, sess *Session) context.Context
- type BaseRunner
- type DeleteRunner
- type ExecRunner
- type FacOpt
- type InsertRunner
- type ObjectCache
- type ParserFactory
- type Runner
- type SelectRunner
- type Session
- func (session *Session) Delete(sql string) Runner
- func (session *Session) Exec(sql string) Runner
- func (session *Session) GetContext() context.Context
- func (session *Session) Insert(sql string) Runner
- func (session *Session) Select(sql string) Runner
- func (session *Session) SetContext(ctx context.Context) *Session
- func (session *Session) SetParserFactory(fac ParserFactory)
- func (session *Session) Tx(txFunc func(session *Session) error) (err error)
- func (session *Session) Update(sql string) Runner
- type SessionManager
- type TableName
- type UpdateRunner
Constants ¶
View Source
const (
ContextSessionKey = "__gobatis_session__"
)
Variables ¶
This section is empty.
Functions ¶
func DynamicParserFactory ¶ added in v0.2.7
func FindDynamicSqlParser ¶ added in v0.2.7
func FindTemplateSqlParser ¶ added in v0.2.7
func NewFactory ¶ added in v0.2.7
func ParseObject ¶
func ParseObject(bean interface{}) (reflection.Object, error)
func RegisterMapperData ¶
func RegisterMapperFile ¶
func RegisterModel ¶
func RegisterModel(model interface{}) error
RegisterModel 注册struct模型,模型描述了column和field之间的关联关系; 目前已非必要条件
func RegisterModelWithName ¶
func RegisterSql ¶
func RegisterTemplateData ¶ added in v0.2.7
func RegisterTemplateFile ¶ added in v0.2.7
func ScanMapperFile ¶ added in v0.2.7
func TemplateParserFactory ¶ added in v0.2.7
func UnregisterSql ¶
func UnregisterSql(sqlId string)
Types ¶
type BaseRunner ¶
type BaseRunner struct {
// contains filtered or unexported fields
}
func (*BaseRunner) Context ¶
func (baseRunner *BaseRunner) Context(ctx context.Context) Runner
Context 设置执行的context
func (*BaseRunner) LastInsertId ¶
func (baseRunner *BaseRunner) LastInsertId() int64
func (*BaseRunner) Param ¶
func (baseRunner *BaseRunner) Param(params ...interface{}) Runner
func (*BaseRunner) Result ¶
func (baseRunner *BaseRunner) Result(bean interface{}) error
type DeleteRunner ¶
type DeleteRunner struct {
BaseRunner
}
func (*DeleteRunner) Result ¶
func (deleteRunner *DeleteRunner) Result(bean interface{}) error
type ExecRunner ¶ added in v0.2.7
type ExecRunner struct {
BaseRunner
}
func (*ExecRunner) Result ¶ added in v0.2.7
func (execRunner *ExecRunner) Result(bean interface{}) error
type FacOpt ¶ added in v0.2.7
type FacOpt func(f *factory.DefaultFactory)
func SetConnMaxLifetime ¶ added in v0.2.7
func SetDataSource ¶ added in v0.2.7
func SetDataSource(ds datasource.DataSource) FacOpt
func SetMaxConn ¶ added in v0.2.7
func SetMaxIdleConn ¶ added in v0.2.7
type InsertRunner ¶
type InsertRunner struct { BaseRunner // contains filtered or unexported fields }
func (*InsertRunner) LastInsertId ¶
func (insertRunner *InsertRunner) LastInsertId() int64
func (*InsertRunner) Result ¶
func (insertRunner *InsertRunner) Result(bean interface{}) error
type ObjectCache ¶
type ObjectCache struct {
// contains filtered or unexported fields
}
type ParserFactory ¶ added in v0.2.7
type Runner ¶
type Runner interface { // Param 参数 // 注意:如果没有参数也必须调用 // 如果参数个数为1并且为struct,将解析struct获得参数 // 如果参数个数大于1并且全部为简单类型,或则个数为1且为简单类型,则使用这些参数 Param(params ...interface{}) Runner // Result 获得结果 Result(bean interface{}) error // LastInsertId 最后插入的自增id LastInsertId() int64 // Context 设置Context Context(ctx context.Context) Runner }
type SelectRunner ¶
type SelectRunner struct {
BaseRunner
}
func (*SelectRunner) Result ¶
func (selectRunner *SelectRunner) Result(bean interface{}) error
type Session ¶
type Session struct { ParserFactory ParserFactory // contains filtered or unexported fields }
func FindSession ¶ added in v0.2.7
func (*Session) GetContext ¶
func (*Session) SetParserFactory ¶ added in v0.2.7
func (session *Session) SetParserFactory(fac ParserFactory)
SetParserFactory 修改sql解析器创建者
type SessionManager ¶
type SessionManager struct { ParserFactory ParserFactory // contains filtered or unexported fields }
func NewSessionManager ¶
func NewSessionManager(factory factory.Factory) *SessionManager
func (*SessionManager) Close ¶ added in v0.2.7
func (sessionManager *SessionManager) Close() error
func (*SessionManager) Context ¶ added in v0.2.7
func (sessionManager *SessionManager) Context(ctx context.Context) context.Context
Context 包含session的context
func (*SessionManager) NewSession ¶
func (sessionManager *SessionManager) NewSession() *Session
NewSession 使用一个session操作数据库
func (*SessionManager) SetParserFactory ¶ added in v0.2.7
func (sessionManager *SessionManager) SetParserFactory(fac ParserFactory)
SetParserFactory 修改sql解析器创建者
type UpdateRunner ¶
type UpdateRunner struct {
BaseRunner
}
func (*UpdateRunner) Result ¶
func (updateRunner *UpdateRunner) Result(bean interface{}) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.