db

package
v0.0.0-...-0cd273a Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDB

func InitDB(driver, url string) (err error)

InitDB creates an instance of xorm.Engine

Types

type EngineInterface

type EngineInterface interface {
	Get(bean interface{}) (bool, error)
	Insert(beans ...interface{}) (int64, error)
	InsertOne(bean interface{}) (int64, error)
	SetMapper(mapper core.IMapper)
	ShowSQL(show ...bool)
	Logger() core.ILogger
	SetLogger(logger core.ILogger)
	NewSession() *xorm.Session
	CreateTables(beans ...interface{}) error
	DropTables(beans ...interface{}) error
	Delete(bean interface{}) (int64, error)
	Close() error
	Id(id interface{}) *xorm.Session
	IsTableExist(beanOrTableName interface{}) (bool, error)
}

EngineInterface is used to mock db methods during unit tests

var Engine EngineInterface

Engine is the main entrypoint for database operations

type SessionInterface

type SessionInterface interface {
	Begin() error
	Close()
	Cols(columns ...string) *xorm.Session
	Id(id interface{}) *xorm.Session
	Insert(beans ...interface{}) (int64, error)
	InsertOne(beans interface{}) (int64, error)
	Commit() error
	Rollback() error
	Update(bean interface{}, condiBean ...interface{}) (int64, error)
}

SessionInterface is used to mock xorm.Session objects during unit tests

Jump to

Keyboard shortcuts

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