mysql

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidDB = fmt.Errorf("invalid db")
View Source
var ErrNoTransaction = fmt.Errorf("no transaction")

Functions

func DiffModel

func DiffModel(curr, prev interface{}) []string

DiffModel 模型差异对比,返回gorm命名规范的更新数据 支持以下类型比对:常规数据类型(bool, int, float, string, time.Time),嵌套可导出的非指针的 struct

func RegisterConverter

func RegisterConverter(entity ddd.IEntity, converter IConverter)

RegisterConverter 使用时直接 mysql.RegisterConverter(&do{}, converter)

func RegisterEntity2Model

func RegisterEntity2Model(entity ddd.IEntity, f1 Entity2Model, f2 Model2Entity)

Types

type Converter

type Converter struct {
	// contains filtered or unexported fields
}

type Entity2Model

type Entity2Model func(entity, parent ddd.IEntity, op ddd.OpType) (IModel, error)

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

func NewExecutor

func NewExecutor(db *gorm.DB) *Executor

func (*Executor) Begin

func (e *Executor) Begin(ctx context.Context) (context.Context, error)

func (*Executor) Commit

func (e *Executor) Commit(ctx context.Context) error

func (*Executor) Diff

func (e *Executor) Diff(ctx context.Context, curr, prev ddd.IModel) ddd.IModel

func (*Executor) Entity2Model

func (e *Executor) Entity2Model(entity, parent ddd.IEntity, op ddd.OpType) (ddd.IModel, error)

func (*Executor) Exec

func (e *Executor) Exec(ctx context.Context, action *ddd.Action) error

func (*Executor) Model2Entity

func (e *Executor) Model2Entity(model ddd.IModel, entity ddd.IEntity) error

func (*Executor) RollBack

func (e *Executor) RollBack(ctx context.Context) error

type IConverter

type IConverter interface {
	Entity2Model(entity, parent ddd.IEntity, op ddd.OpType) (IModel, error)
	Model2Entity(po IModel, do ddd.IEntity) error
}

type IModel

type IModel interface {
	GetID() string
	TableName() string
}

type Model2Entity

type Model2Entity func(po IModel, do ddd.IEntity) error

Jump to

Keyboard shortcuts

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