emysql

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FieldsError = fmt.Errorf("fileds length is 0")
)
View Source
var MysqlMap sync.Map

Functions

func BulkInsert

func BulkInsert(db *gorm.DB, table string, fields []string, params []map[string]interface{}) error

@desc @auth liuguoqiang 2020-11-27 @param @return

func BulkSave

func BulkSave(db *gorm.DB, table string, fields []string, params []map[string]interface{}) error

@desc 批量插入 @auth liuguoqiang 2020-11-27 @param @return

func GetMysql added in v1.1.8

func GetMysql(ctx context.Context, dbName string) *gorm.DB

GetMysql return a MysqlClient

func Transaction added in v1.1.10

func Transaction(ctx context.Context, f func(context.Context) error) (err error)

注意:该事务不是并发安全的

func Validate

func Validate(data, model interface{}) bool

@desc @auth liuguoqiang 2020-04-08 @param @return

Types

type Client

type Client interface {
	GetDB(key string) *gorm.DB
}

type DefaultClient

type DefaultClient struct {
	Client
}

type GetMysqlDB

type GetMysqlDB func(key string) *gorm.DB
var GetDB GetMysqlDB

type Map

type Map map[string]interface{}

func (*Map) Scan added in v1.1.8

func (m *Map) Scan(input interface{}) error

Scan 实现方法

func (Map) Value added in v1.1.8

func (m Map) Value() (driver.Value, error)

Value 实现方法

type MysqlClient

type MysqlClient struct {
	*gorm.DB
	// contains filtered or unexported fields
}

func NewMysqlClient

func NewMysqlClient(config *emysql_config.Config, options ...Option) (*MysqlClient, error)

NewMysqlClient ...

func (*MysqlClient) WithContext

func (m *MysqlClient) WithContext(ctx context.Context) *MysqlClient

WithContext ...

type Option

type Option func(c *emysql_config.Config)

Option 可选项

func WithInterceptor

func WithInterceptor(is ...emysql_config.Interceptor) Option

WithInterceptor 设置自定义拦截器

type TransactionKeyType added in v1.1.10

type TransactionKeyType string
const TxDBMap TransactionKeyType = "TxDBMap"
const TxOpen TransactionKeyType = "TxOpen"

Directories

Path Synopsis
internal
dsn

Jump to

Keyboard shortcuts

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