mysql

package
v1.3.40 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultCharset          = "utf8mb4"
	DefaultLoc              = "Local"
	DefaultParseTime        = "true"
	DefaultMaxAllowedPacket = "0"
	DefaultTimeout          = "15s"
)
View Source
const (
	DefaultLogLevel      = logger.Warn
	DefaultSlowThreshold = 500 * time.Millisecond
)
View Source
const (
	DefaultMaxIdleConns    = 5
	DefaultMaxOpenConns    = 50
	DefaultConnMaxIdleTime = 5 * time.Minute
	DefaultConnMaxLifeTime = 10 * time.Minute
)

Variables

View Source
var (
	ErrNilPointer     = errors.New("invalid data or nil pointer")
	ErrMustPtrData    = errors.New("data must be a pointer")
	ErrMissPrimaryKey = errors.New("primary key not found")
)

Functions

This section is empty.

Types

type Model

type Model struct {
	Table string
	Data  interface{}
	DB    func() *gorm.DB
}

func (*Model) AllFields added in v1.3.40

func (m *Model) AllFields(withBackQuote bool) string

func (*Model) Count

func (m *Model) Count(where []interface{}) (count int64)

func (*Model) Create added in v1.3.40

func (m *Model) Create(value interface{}) (interface{}, error)

func (*Model) DebugLogger added in v1.3.40

func (m *Model) DebugLogger() logger.Interface

func (*Model) Delete

func (m *Model) Delete(where []interface{}) error

func (*Model) Dialector added in v1.2.0

func (m *Model) Dialector(dialect *types.MysqlDialect) gorm.Dialector

func (*Model) Find

func (m *Model) Find(des interface{}, where []interface{}, fields interface{}, order interface{}, offset int, limit int)

func (*Model) FindByPrimaryKey added in v1.3.40

func (m *Model) FindByPrimaryKey(des interface{}, value interface{}, fields interface{})

func (*Model) FindOne

func (m *Model) FindOne(des interface{}, where []interface{}, fields interface{}, order interface{})

func (*Model) GetPrimaryKeyFieldName added in v1.3.40

func (m *Model) GetPrimaryKeyFieldName() (string, error)

func (*Model) NewLogger added in v1.3.40

func (m *Model) NewLogger(filename string, args ...interface{}) logger.Interface

func (*Model) NewMysql

func (m *Model) NewMysql(collector *types.DBCollector, dialect *types.MysqlDialect, options ...Option) (*gorm.DB, error)

func (*Model) ParseDSN added in v1.2.0

func (m *Model) ParseDSN(dialect *types.MysqlDialect) string

func (*Model) Save

func (m *Model) Save(value interface{}, args ...interface{}) (interface{}, error)

func (*Model) SaveOrUpdate added in v1.1.6

func (m *Model) SaveOrUpdate(value interface{}, primaryKey int, updateFields interface{}) (interface{}, error)

func (*Model) Session added in v1.3.40

func (m *Model) Session() *gorm.DB

func (*Model) Update

func (m *Model) Update(where []interface{}, value interface{}) error

func (*Model) WithConnMaxIdleTime added in v1.3.40

func (*Model) WithConnMaxIdleTime(t time.Duration) Option

func (*Model) WithConnMaxLifeTime added in v1.3.40

func (*Model) WithConnMaxLifeTime(t time.Duration) Option

func (*Model) WithDebugLogger added in v1.3.40

func (m *Model) WithDebugLogger() Option

func (*Model) WithLogger added in v1.3.40

func (*Model) WithLogger(args ...interface{}) Option

func (*Model) WithMaxIdleConns added in v1.3.40

func (*Model) WithMaxIdleConns(i int) Option

func (*Model) WithMaxOpenConns added in v1.3.40

func (*Model) WithMaxOpenConns(i int) Option

type Option added in v1.3.40

type Option func(c *modelConfig)

Jump to

Keyboard shortcuts

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