Documentation ¶
Index ¶
- func ErrCancelledf(format string, args ...interface{}) error
- func GetEngine(ctx context.Context) xorm.Interface
- func InTransaction(ctx context.Context) bool
- func IsErrCancelled(err error) bool
- func IsErrNotExist(err error) bool
- func SetDefaultEngine(ctx context.Context, eng *xorm.Engine)
- func TxContext(parentCtx context.Context) (*Context, Committer, error)
- func UnsetDefaultEngine()
- func WithTx(parentCtx context.Context, f func(ctx context.Context) error) error
- type Committer
- type Context
- type Engined
- type ErrCancelled
- type ErrNotExist
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrCancelledf ¶
ErrCancelledf returns an ErrCancelled for the provided format and args
func GetEngine ¶
GetEngine will get a db Engine from this context or return an Engine restricted to this context
func InTransaction ¶
InTransaction returns true if the engine is in a transaction otherwise return false
func IsErrCancelled ¶
IsErrCancelled checks if an error is a ErrCancelled.
func IsErrNotExist ¶
IsErrNotExist checks if an error is an ErrNotExist
func SetDefaultEngine ¶
SetDefaultEngine sets the default engine for db
func TxContext ¶
TxContext represents a transaction Context, it will reuse the existing transaction in the parent context or create a new one.
func UnsetDefaultEngine ¶
func UnsetDefaultEngine()
UnsetDefaultEngine closes and unsets the default engine We hope the SetDefaultEngine and UnsetDefaultEngine can be paired, but it's impossible now, there are many calls to InitEngine -> SetDefaultEngine directly to overwrite the `x` and DefaultContext without close Global database engine related functions are all racy and there is no graceful close right now.
Types ¶
type Context ¶
Context represents a db context
func (*Context) InTransaction ¶
InTransaction if context is in a transaction
type ErrCancelled ¶
type ErrCancelled struct {
Message string
}
ErrCancelled represents an error due to context cancellation
func (ErrCancelled) Error ¶
func (err ErrCancelled) Error() string
type ErrNotExist ¶
ErrNotExist represents a non-exist error.
func (ErrNotExist) Error ¶
func (err ErrNotExist) Error() string