mysql

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterDeleted

func FilterDeleted() func(db *gorm.DB) *gorm.DB

func NewKidLogger

func NewKidLogger(config *gLogger.Config) gLogger.Interface

func Paginate

func Paginate(pageNum, pageSize int) func(db *gorm.DB) *gorm.DB
func Search(where map[string]interface{}) func(db *gorm.DB) *gorm.DB

Search 搜索 多个值 当有值

func Where

func Where(where map[string]interface{}) func(db *gorm.DB) *gorm.DB

Types

type AutoMigrate

type AutoMigrate interface {
	Models() []interface{}
}

type DB added in v1.0.36

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

func Default added in v1.0.14

func Default() *DB

func New

func New(opts ...Option) *DB

func (*DB) Provide added in v1.0.36

func (conn *DB) Provide() interface{}

type KidLogger

type KidLogger struct {
	logger.Logger
	*gLogger.Config
	// contains filtered or unexported fields
}

func (*KidLogger) Error

func (log *KidLogger) Error(ctx context.Context, msg string, data ...interface{})

func (*KidLogger) Info

func (log *KidLogger) Info(ctx context.Context, msg string, data ...interface{})

func (*KidLogger) LogMode

func (log *KidLogger) LogMode(level gLogger.LogLevel) gLogger.Interface

func (*KidLogger) Trace

func (log *KidLogger) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error)

func (*KidLogger) Warn

func (log *KidLogger) Warn(ctx context.Context, msg string, data ...interface{})

type Option

type Option func(*Options)

func WithDb

func WithDb(dbName string) Option

func WithHost

func WithHost(host string) Option

func WithLogLevel

func WithLogLevel(logLevel int) Option

func WithMaxIdle

func WithMaxIdle(maxIdle int) Option

func WithMaxLife

func WithMaxLife(maxLife time.Duration) Option

func WithMaxOpen

func WithMaxOpen(maxOpen int) Option

func WithPassword

func WithPassword(password string) Option

func WithPort

func WithPort(port int) Option

func WithUser

func WithUser(user string) Option

type Options

type Options struct {
	User     string        // 数据库用户名
	Password string        // 数据库密码
	Host     string        // 数据库连接地址
	Port     int           // 数据库连接端口
	Db       string        // 数据库库名
	MaxIdle  int           // 最大空闲连接数
	MaxOpen  int           // 最大连接数
	MaxLife  time.Duration // 连接最大存活时间
	LogLevel int           // 日志级别
}

Jump to

Keyboard shortcuts

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