session

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const NameSpace = "github.com/avicd/go-sqlx"
View Source
const SelectSetSuffix = "!SelectSet"

Variables

This section is empty.

Functions

func InName

func InName(i int, names []string) string

func OutName

func OutName(i int) string

func StmtIdOf

func StmtIdOf(id string) string

Types

type Config

type Config struct {
	XmlScan string
	// contains filtered or unexported fields
}

func (*Config) AddNs

func (it *Config) AddNs(ns string, xml string)

func (*Config) AddPlugin

func (it *Config) AddPlugin(plugin Plugin)

func (*Config) AddRsMap

func (it *Config) AddRsMap(id string, rsMap RsMap)

func (*Config) AddStmt

func (it *Config) AddStmt(stmt *Stmt)

func (*Config) Factory

func (it *Config) Factory() *Factory

func (*Config) GetDB

func (it *Config) GetDB(id string) *sql.DB

func (*Config) GetNsXml

func (it *Config) GetNsXml(ns string) string

func (*Config) GetRsMap

func (it *Config) GetRsMap(id string) RsMap

func (*Config) GetStmt

func (it *Config) GetStmt(id string) *Stmt

func (*Config) HasNs

func (it *Config) HasNs(ns string) bool

func (*Config) MainDB

func (it *Config) MainDB() *sql.DB

func (*Config) SetDB

func (it *Config) SetDB(id string, db *sql.DB) *Config

func (*Config) SetMainDB

func (it *Config) SetMainDB(db *sql.DB)

type DBProxy

type DBProxy interface {
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

type Factory

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

func (*Factory) Keeper

func (it *Factory) Keeper() *Keeper

func (*Factory) Open

func (it *Factory) Open() *Session

func (*Factory) OpenTx

func (it *Factory) OpenTx() *Session

func (*Factory) OpenTxWith

func (it *Factory) OpenTxWith(txOpts *sql.TxOptions) *Session

func (*Factory) ResetKeeper

func (it *Factory) ResetKeeper()

type Hook

type Hook = int
const (
	ProcessArgs Hook = iota
	SqlQuery
	ProcessResults
	Always
)

type Keeper

type Keeper struct {
	Context context.Context
	// contains filtered or unexported fields
}

func (*Keeper) Commit

func (it *Keeper) Commit()

func (*Keeper) Current

func (it *Keeper) Current() *Session

func (*Keeper) Locked

func (it *Keeper) Locked() bool

func (*Keeper) Pop

func (it *Keeper) Pop()

func (*Keeper) Push

func (it *Keeper) Push(session *Session)

func (*Keeper) Reuse

func (it *Keeper) Reuse()

func (*Keeper) Rollback

func (it *Keeper) Rollback()

type Order

type Order = int
const (
	Before Order = iota
	After
)

type Payload

type Payload struct {
	Stmt         *Stmt
	Args         []reflect.Value
	Sql          string
	SqlArgs      []any
	Result       []reflect.Value
	LastInsertId int64
	// contains filtered or unexported fields
}

func (*Payload) Cancel

func (it *Payload) Cancel()

func (*Payload) Put

func (it *Payload) Put(key string, value any)

func (*Payload) PutAll

func (it *Payload) PutAll(val map[string]any)

type Plugin

type Plugin interface {
	Intercept(payload *Payload) bool
	Hook() Hook
	Order() Order
	Id() int
}

type Proxy

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

func (*Proxy) Invoker

func (it *Proxy) Invoker() reflect.Value

type RsMap

type RsMap = map[string][]string

type Session

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

func (*Session) Commit

func (it *Session) Commit()

func (*Session) Exec

func (it *Session) Exec(stmt *Stmt, sql string, values []any) (sql.Result, error)

func (*Session) Query

func (it *Session) Query(stmt *Stmt, sql string, values []any) (*sql.Rows, error)

func (*Session) Rollback

func (it *Session) Rollback()

type SetProxy

type SetProxy struct {
	Invoker reflect.Value
	Props   []any
	Bind    string
	Basic   bool
	SetMap  map[string][]string
}

type Stmt

type Stmt struct {
	Id         string
	Ns         string
	DbId       string
	SqlNode    script.SqlNode
	Dynamic    bool
	RsMaps     []RsMap
	StmtType   StmtType
	ArgNames   []string
	KeyProps   []string
	KeyColumns []string
	Target     Target
	Bind       string
	SetStmts   []*Stmt
	// contains filtered or unexported fields
}

func (*Stmt) DB

func (it *Stmt) DB() *sql.DB

func (*Stmt) EvalSql

func (it *Stmt) EvalSql(builder *script.SqlBuilder) (string, []any)

func (*Stmt) ProxyOf

func (it *Stmt) ProxyOf(target reflect.Type, args ...string) *Proxy

func (*Stmt) ProxyOfField

func (it *Stmt) ProxyOfField(tf reflect.StructField) *Proxy

func (*Stmt) Scan

func (it *Stmt) Scan(dest any)

type StmtType

type StmtType uint
const (
	Select StmtType = iota
	SelectSet
	Insert
	Update
	Delete
)

type Target

type Target uint
const (
	ARG Target = iota
	RESULT
	CONTEXT
)

Jump to

Keyboard shortcuts

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