model

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound 空记录
	ErrNotFound = gorm.ErrRecordNotFound
)

Functions

func CloseDB added in v1.3.1

func CloseDB() error

CloseDB 关闭连接

func GetDB added in v1.3.0

func GetDB() *gorm.DB

GetDB 返回db对象

func InitMysql added in v1.3.0

func InitMysql(addr string)

InitMysql 连接mysql

Types

type UserExample

type UserExample struct {
	mysql.Model `gorm:"embedded"`

	Name     string `gorm:"column:name;NOT NULL" json:"name"`         // 用户名
	Password string `gorm:"column:password;NOT NULL" json:"password"` // 密码
	Email    string `gorm:"column:email;NOT NULL" json:"email"`       // 邮件
	Phone    string `gorm:"column:phone;NOT NULL" json:"phone"`       // 手机号码
	Avatar   string `gorm:"column:avatar;NOT NULL" json:"avatar"`     // 头像
	Age      int    `gorm:"column:age;NOT NULL" json:"age"`           // 年龄
	Gender   int    `gorm:"column:gender;NOT NULL" json:"gender"`     // 性别,1:男,2:女,其他值:未知
	Status   int    `gorm:"column:status;NOT NULL" json:"status"`     // 账号状态,1:未激活,2:已激活,3:封禁
	LoginAt  int64  `gorm:"column:login_at;NOT NULL" json:"login_at"` // 登录时间戳
}

UserExample object fields mapping table

func (*UserExample) TableName

func (table *UserExample) TableName() string

TableName get table name

Jump to

Keyboard shortcuts

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