orm

package
v1.6.5 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCtxLogger added in v1.6.0

func RegisterCtxLogger(ctxLog xormLog.ContextLogger)

Types

type Logger

type Logger struct {
	*logrus.Entry
	// contains filtered or unexported fields
}

func (*Logger) IsShowSQL

func (l *Logger) IsShowSQL() bool

func (*Logger) Level

func (l *Logger) Level() xormLog.LogLevel

func (*Logger) SetLevel

func (l *Logger) SetLevel(c xormLog.LogLevel)

func (*Logger) ShowSQL

func (l *Logger) ShowSQL(show ...bool)

type Orm

type Orm struct {
	*xorm.Engine
}

func Ins

func Ins(id ...string) *Orm

返回 orm 组件单例

func (*Orm) Transactional

func (o *Orm) Transactional(f func(session *xorm.Session) error, opts ...OrmOption) (err error)

扩展了一个事务功能

func (*Orm) Upsert added in v1.5.3

func (o *Orm) Upsert(table interface{}, columns map[string]interface{}, opts ...OrmOption) (sql.Result, error)

添加或者修改的原子操作,但是要求 columns 里面必须包含唯一键,否则会一直执行添加操作 Upsert("table_name",g.Hash{"name":"zhangsan","uuid":"abcdef"}) Upsert("table_name",g.Hash{"name":"zhangsan","uuid":"abcdef"},orm.WithSession(session)) 事务中使用

type OrmArg added in v1.5.3

type OrmArg struct {
	Session *xorm.Session
	// contains filtered or unexported fields
}

func ExtractOption added in v1.5.3

func ExtractOption(opts ...OrmOption) OrmArg

type OrmOption added in v1.5.3

type OrmOption func(arg *OrmArg)

func WithContext added in v1.6.0

func WithContext(ctx context.Context) OrmOption

func WithSession added in v1.5.3

func WithSession(session *xorm.Session) OrmOption

Jump to

Keyboard shortcuts

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