gouow

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const TX_KEY key = "unit_of_work"

TX_KEY key for store and get value from context

Variables

This section is empty.

Functions

This section is empty.

Types

type TX

type TX struct {
	Tx    interface{}
	UseTx bool
}

TX transaction structure for keep transaction sql

func (*TX) GormDB

func (tx *TX) GormDB() *gorm.DB

GormDB get gorm db engine

func (*TX) SqlDB

func (tx *TX) SqlDB() *sql.Tx

SqlDB get sql db engine

type UnitOfWorkInterface

type UnitOfWorkInterface interface {
	NewSession(ctx *context.Context) error
	BeginTx(ctx context.Context, operation func(ctxTx context.Context) error) error
	Commit() error
	Rollback(err error) error
}

func Init

func Init(db interface{}) UnitOfWorkInterface

Init initialize new unit of work package

Jump to

Keyboard shortcuts

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