Documentation
¶
Index ¶
- func Close() (err error)
- func GetDB() *gorm.DB
- func InitMysqlDB(host, username, password, dbname string, maxOpen, maxIdle int) (err error)
- func InitSqliteDB(dbfile string) (err error)
- func NewMysqlDB(host, username, password, dbname string, maxOpen, maxIdle int) (d *gorm.DB, err error)
- func NewSqliteDB(dbfile string) (d *gorm.DB, err error)
- type Model
- type Paginator
- type Param
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitMysqlDB ¶
初始化默认mysql数据库
Types ¶
type Model ¶
type Model struct {
// 唯一标识
ID uint `json:"id" gorm:"primary_key"`
// 创建时间
CreatedAt int64 `json:"created_at"`
// 更新时间
UpdatedAt int64 `json:"updated_at"`
// 删除时间
DeletedAt *int64 `sql:"index" json:"deleted_at,omitempty"`
}
自己参照gorm.model定义也可以的,可以重写json tag
type Paginator ¶
type Paginator struct {
TotalRecord int `json:"total_record"`
TotalPage int `json:"total_page"`
Records interface{} `json:"list"`
Offset int `json:"offset"`
Limit int `json:"limit"`
Page int `json:"page"`
PrevPage int `json:"prev_page"`
NextPage int `json:"next_page"`
}
Paginator 分页返回
Click to show internal directories.
Click to hide internal directories.