sqlt

package module
v0.0.0-...-752b63c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

README

sqlt

like mybatis see README-zh.md

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug = false
View Source
var (
	DefaultManifest = Manifest{
		Default: Config{
			TimeOut:  0,
			ReadOnly: false,
			Extra:    make(map[string]interface{}),
		},
		ConfigMap: make(map[string]Config),
	}
)
View Source
var (
	DefaultTxOptions *sql.TxOptions = NewTxOptions(sql.LevelDefault, false)
)

Functions

func NewTxOptions

func NewTxOptions(level sql.IsolationLevel, readonly bool) *sql.TxOptions

Types

type Config

type Config struct {
	TimeOut  int64
	ReadOnly bool
	Extra    map[string]interface{}
}

type DbOp

type DbOp struct {
	// contains filtered or unexported fields
}

func NewSqlt

func NewSqlt(dbset dsds.DbManager, loader SqlAssembler) *DbOp

func (*DbOp) BeginTx

func (c *DbOp) BeginTx(ctx context.Context, opt *sql.TxOptions) (*TxOp, error)

func (*DbOp) BeginTxWithDb

func (c *DbOp) BeginTxWithDb(ctx context.Context, i interface{}, opt *sql.TxOptions) (*TxOp, error)

func (*DbOp) Exec

func (c *DbOp) Exec(id string, data interface{}) (int64, error)

func (*DbOp) ExecContext

func (c *DbOp) ExecContext(ctx context.Context, id string, data interface{}) (int64, error)

func (*DbOp) ExecRtn

func (c *DbOp) ExecRtn(id string, data interface{}, mrh MultiRowsHandler) error

func (*DbOp) ExecRtnContext

func (c *DbOp) ExecRtnContext(ctx context.Context, id string, data interface{}, mrh MultiRowsHandler) error

func (*DbOp) Query

func (c *DbOp) Query(id string, data interface{}, mrh MultiRowsHandler) error

func (*DbOp) QueryContext

func (c *DbOp) QueryContext(ctx context.Context, id string, data interface{}, mrh MultiRowsHandler) error

type Manifest

type Manifest struct {
	Default   Config
	ConfigMap map[string]Config
}

func (Manifest) GetConfigCopy

func (m Manifest) GetConfigCopy(id string) Config

type MultiRowsHandler

type MultiRowsHandler interface {
	HandleRow(r RowScanner)
	AddResultSet()
}

type NestableSqlAssmbler

type NestableSqlAssmbler interface {
	SqlAssembler
	HasId(id string) bool
}

type RowScanner

type RowScanner interface {
	Columns() ([]string, error)
	Scan(dest ...interface{}) error
	Err() error
}

type SqlAssembler

type SqlAssembler interface {
	AssembleSql(id string, data interface{}) (SqlDescriber, error)
}

type SqlAssemblerSet

type SqlAssemblerSet struct {
	// contains filtered or unexported fields
}

func NewSqlAssemblerSet

func NewSqlAssemblerSet(def SqlAssembler, assemblers ...NestableSqlAssmbler) *SqlAssemblerSet

func (*SqlAssemblerSet) AssembleSql

func (n *SqlAssemblerSet) AssembleSql(id string, data interface{}) (SqlDescriber, error)

type SqlDescriber

type SqlDescriber interface {
	GetSql(c context.Context) (string, context.Context, error)
	Release()
}

type SqlRender

type SqlRender interface {
	Render(w io.Writer, id string, param interface{}) error
}

type StdSqlAssembler

type StdSqlAssembler struct {
	Render   SqlRender
	Manifest Manifest
}

func NewStdSqlAssembler

func NewStdSqlAssembler(r SqlRender, m Manifest) *StdSqlAssembler

func NewStdSqlAssemblerDefault

func NewStdSqlAssemblerDefault(pattern string) *StdSqlAssembler

func (*StdSqlAssembler) AssembleSql

func (l *StdSqlAssembler) AssembleSql(id string, data interface{}) (SqlDescriber, error)

type StdSqlDescriber

type StdSqlDescriber struct {
	Id     string
	Data   interface{}
	Config Config
	bytes.Buffer
	// contains filtered or unexported fields
}

func (*StdSqlDescriber) GetSql

func (*StdSqlDescriber) IsReadOnly

func (s *StdSqlDescriber) IsReadOnly() bool

func (*StdSqlDescriber) Release

func (s *StdSqlDescriber) Release()

func (*StdSqlDescriber) WithContext

func (s *StdSqlDescriber) WithContext(c context.Context) context.Context

type StdTemplateRender

type StdTemplateRender struct {
	// contains filtered or unexported fields
}

func NewStdTemplateRender

func NewStdTemplateRender(pattern string, funcMap template.FuncMap) *StdTemplateRender

func NewStdTemplateRenderDefault

func NewStdTemplateRenderDefault(pattern string) *StdTemplateRender

func (*StdTemplateRender) Render

func (st *StdTemplateRender) Render(w io.Writer, id string, param interface{}) error

type TxOp

type TxOp struct {
	// contains filtered or unexported fields
}

func (*TxOp) Commit

func (c *TxOp) Commit() error

func (*TxOp) Exec

func (c *TxOp) Exec(id string, data interface{}) (int64, error)

func (*TxOp) ExecContext

func (c *TxOp) ExecContext(ctx context.Context, id string, data interface{}) (int64, error)

func (*TxOp) ExecRtn

func (c *TxOp) ExecRtn(id string, data interface{}, mrh MultiRowsHandler) error

func (*TxOp) ExecRtnContext

func (c *TxOp) ExecRtnContext(ctx context.Context, id string, data interface{}, mrh MultiRowsHandler) error

func (*TxOp) Query

func (c *TxOp) Query(id string, data interface{}, mrh MultiRowsHandler) error

func (*TxOp) QueryContext

func (c *TxOp) QueryContext(ctx context.Context, id string, data interface{}, mrh MultiRowsHandler) error

func (*TxOp) Rollback

func (c *TxOp) Rollback() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL