gormx

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: MulanPSL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SQLModeDebug   = "debug"
	SQLModeRelease = "release"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v1.0.6

type Config struct {
	Usage       string // use to manage connection
	RunMode     string // debug, release
	DSN         string // root:root@tcp(127.0.0.1:3306)
	Database    string // default database
	MaxIdleConn int
	MaxOpenConn int
	MaxLifeTime int
}

Config init config

type Manager added in v1.0.6

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

Manager store all gorm db engine according to the config usage key

func New added in v1.0.6

func New(configs []*Config) *Manager

New return a gorm db Manager

func (*Manager) Default added in v1.0.6

func (m *Manager) Default() *gorm.DB

Default return default engine, default is the first config in configs

func (*Manager) MustUse added in v1.0.6

func (m *Manager) MustUse(ctx context.Context) *gorm.DB

MustUse return default engine, default is the first config in configs, if err, got panic

func (*Manager) SetWriters added in v1.0.6

func (m *Manager) SetWriters(writers ...io.Writer)

SetWriters set gorm log writers, default is stdout

func (*Manager) Use added in v1.0.6

func (m *Manager) Use(ctx context.Context, key string) (*gorm.DB, error)

Use return engine from incoming key

type OpenTracingPlugin added in v1.0.6

type OpenTracingPlugin struct{}

func (*OpenTracingPlugin) Initialize added in v1.0.6

func (op *OpenTracingPlugin) Initialize(db *gorm.DB) (err error)

func (*OpenTracingPlugin) Name added in v1.0.6

func (op *OpenTracingPlugin) Name() string

type SQL added in v1.0.6

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

func MockSQLTesting added in v1.0.6

func MockSQLTesting(t *testing.T) *SQL

func (*SQL) Close added in v1.0.6

func (s *SQL) Close()

func (*SQL) DB added in v1.0.6

func (s *SQL) DB() *_sql.DB

func (*SQL) GormDB added in v1.0.6

func (s *SQL) GormDB() *gorm.DB

func (*SQL) Mock added in v1.0.6

func (s *SQL) Mock() sqlmock.Sqlmock

type SimpleGormBridge

type SimpleGormBridge interface {
	Create(t schema.Tabler, v interface{}) error
	Update(t schema.Tabler, v interface{}, kv interface{}) error
	Delete(v schema.Tabler, kv interface{}) (int64, error)
	First(t schema.Tabler, v interface{}, kv interface{}) error
}

func NewBridge

func NewBridge(db *gorm.DB, key string) SimpleGormBridge

Jump to

Keyboard shortcuts

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