orm

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: May 25, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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() core.LogLevel

func (*Logger) SetLevel

func (l *Logger) SetLevel(c core.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 (orm *Orm) Transactional(f func(session *xorm.Session) error) (err error)

扩展了一个事务功能

func (*Orm) Upsert added in v1.6.0

func (orm *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.6.0

type OrmArg struct {
	Session *xorm.Session
}

func ExtractOption added in v1.6.0

func ExtractOption(opts ...OrmOption) OrmArg

type OrmOption added in v1.6.0

type OrmOption func(arg *OrmArg)

func WithSession added in v1.6.0

func WithSession(session *xorm.Session) OrmOption

Jump to

Keyboard shortcuts

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