Documentation ¶
Index ¶
- Variables
- func AutoMigrate(db *gorm.DB, dbType string) error
- func Check(db *gorm.DB) (bool, error)
- func FindOne(db *gorm.DB, out interface{}) (bool, error)
- func FindPage(db *gorm.DB, pp pagination.Param, out interface{}) (int64, error)
- func GetAssignDB(dbName string) (*gorm.DB, bool)
- func NewDB(c *Config) (*gorm.DB, func(), error)
- func NewMulitDB(cs map[string]*Config) (func(), []error)
- func WrapPageQuery(db *gorm.DB, pp pagination.Param, out interface{}) (int64, error)
- type Config
- type Model
Constants ¶
This section is empty.
Variables ¶
View Source
var (
MulitDB map[string]*gorm.DB
)
MulitDB 多数据库源
Functions ¶
func WrapPageQuery ¶
WrapPageQuery 包装带有分页的查询
Types ¶
type Config ¶
type Config struct { Debug bool DBType string DBName string DSN string MaxLifetime int MaxOpenConns int MaxIdleConns int TablePrefix string EnableAutoMigrate bool }
Config 数据库配置
type Model ¶ added in v2.0.31
type Model struct { CreatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP;comment:创建时间;" json:"createdAt"` // 创建时间 UpdatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间;" json:"updatedAt"` // 更新时间 DeletedAt *time.Time `gorm:"type:timestamp;index;comment:删除时间;" json:"deletedAt"` // 删除时间 }
Click to show internal directories.
Click to hide internal directories.