db

package
v0.0.0-...-654a53c Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TransactionStateGlobal     = "Non-Transaction" // 全局连接,未开启事务
	TransactionStateProcessing = "Processing"      // 已开启事务,正在处理中
	TransactionStateCommit     = "Commit"          // 事务已提交
	TransactionStateRollback   = "Rollback"        // 事务已回滚
)
View Source
const CTXDatabase = "CTX_DB"

Variables

This section is empty.

Functions

func InitDB

func InitDB(scripts ...string) *gorm.DB

初始化数据库 建立数据库连接、ORM,并执行外部传入的脚本进行

func TxID

func TxID(st *gorm.Statement) string

Types

type Database

type Database struct {
	DSN     string
	Session *gorm.DB
	Config  *gorm.Config
	State   TransactionState
	Error   error
}
var DB Database

func NewDB

func NewDB() *Database

func NewWithTx

func NewWithTx(tx *gorm.DB) *Database

func (*Database) String

func (db *Database) String() string

type Result

type Result struct {
	Error        error
	RowsAffected int64
}

type TransactionState

type TransactionState string

Jump to

Keyboard shortcuts

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