trans

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: MIT Imports: 2 Imported by: 2

Documentation

Overview

Package trans gorm 事务封装

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxDB added in v0.3.5

func CtxDB(ctx context.Context) func(db *gorm.DB) *gorm.DB

CtxDB ctx scopes db 如果上下文中有事务,返回事务,否则使用db

func Exec added in v0.3.5

func Exec(ctx context.Context, db *gorm.DB, cb func(context.Context) error) error

Exec 执行事务

func NewTransCtx added in v0.3.0

func NewTransCtx(ctx context.Context, trans *Trans) context.Context

NewTransCtx 创建事务的上下文

Types

type Trans

type Trans struct {
	*gorm.DB
}

Trans 事务管理

func FromTransCtx added in v0.3.0

func FromTransCtx(ctx context.Context) *Trans

FromTransCtx 从上下文中获取事务

func New added in v0.2.7

func New(db *gorm.DB) *Trans

New 创建事务管理实例

func (*Trans) Begin

func (sf *Trans) Begin() *Trans

Begin 开启事务,返回事务句柄

Jump to

Keyboard shortcuts

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