mysql_gorm

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDefaultGormDb added in v0.0.4

func NewDefaultGormDb(config Config) *gorm.DB

NewDefaultGormDb new a default gorm db,generally used in svc.NewServiceContext(c config.Config) *ServiceContext

func NewGormDbWithDriverConfig added in v0.0.4

func NewGormDbWithDriverConfig(driverConfig mysql.Config, config Config) *gorm.DB

Types

type Config

type Config struct {
	Path         string          // 服务器地址:端口
	Port         int             `json:",default=3306"` // 端口
	Config       string          // 高级配置
	Dbname       string          // 数据库名
	Username     string          // 数据库用户名
	Password     string          // 数据库密码
	MaxIdleConns int             // 空闲中的最大连接数
	MaxOpenConns int             // 打开到数据库的最大连接数
	LogMode      logger.LogLevel // 是否开启Gorm全局日志
	LogZap       bool            `json:"LogZap,optional,default=false"` // 是否通过zap写入日志文件
}

func (*Config) Dsn

func (m *Config) Dsn() string

type GormBaseModel added in v0.0.4

type GormBaseModel struct {
	CreatedAt int64          `json:"created_at" gorm:"autoCreateTime:milli"`
	UpdatedAt int64          `json:"updated_at" gorm:"autoUpdateTime:milli"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}

type GormBaseModelWithId added in v0.0.4

type GormBaseModelWithId struct {
	Id uint `json:"id" gorm:"primaryKey"` //id
	GormBaseModel
}

type GormBaseModelWithOutLogicDelete added in v0.0.4

type GormBaseModelWithOutLogicDelete struct {
	CreatedAt int64 `json:"created_at" gorm:"autoCreateTime:milli"`
	UpdatedAt int64 `json:"updated_at" gorm:"autoUpdateTime:milli"`
}

Jump to

Keyboard shortcuts

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