Documentation ¶
Index ¶
- type Database
- type Model
- type ModelID
- type ModelNoJSON
- type Option
- func WithDBName(dbname string) Option
- func WithDialect(dialect string) Option
- func WithHost(host string) Option
- func WithLogDebug(logDebug bool) Option
- func WithMaxConnLifeTime(maxConnLifeTime int) Option
- func WithMaxIdleConns(maxIdleConns int) Option
- func WithMaxOpenConns(maxOpenConns int) Option
- func WithPassword(password string) Option
- func WithPort(port int) Option
- func WithUsername(username string) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database interface { Open() error DB() *gorm.DB AutoMigrate(values ...interface{}) (Database, error) Close() // contains filtered or unexported methods }
Database 数据库
type Model ¶ added in v0.4.1
type Model struct { CreatedAt int64 `gorm:"comment:'记录创建时间'" json:"createdAt"` UpdatedAt int64 `gorm:"comment:'最后一次更新时间'" json:"updatedAt"` DeletedAt gorm.DeletedAt `gorm:"index;comment:'软删除时间'" json:"deletedAt"` }
Model 替代 gorm.Model,无 id,需要自定义主键 时间为 秒,
type ModelNoJSON ¶ added in v0.20.6
type ModelNoJSON struct { CreatedAt int64 `gorm:"comment:'记录创建时间'" json:"-"` UpdatedAt int64 `gorm:"comment:'最后一次更新时间'" json:"-"` DeletedAt gorm.DeletedAt `gorm:"index;comment:'软删除时间'" json:"-"` }
ModelNoJSON 同 Model
type Option ¶
type Option func(Database)
Option ..
func WithMaxConnLifeTime ¶
WithMaxConnLifeTime 数据库 maxConnLifeTime
func WithMaxIdleConns ¶
WithMaxIdleConns 数据库 maxIdleConns
func WithMaxOpenConns ¶
WithMaxOpenConns 数据库 maxOpenConns
Click to show internal directories.
Click to hide internal directories.