model

package
v0.0.0-...-c0e02ee Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostM

type PostM struct {
	ID        int64     `gorm:"column:id;primary_key"`
	Username  string    `gorm:"column:username;not null"`
	PostID    string    `gorm:"column:postID;not null"`
	UserID    string    `gorm:"column:user_id;not null"`
	Title     string    `gorm:"column:title;not null"`
	Content   string    `gorm:"column:content"`
	CreatedAt time.Time `gorm:"column:created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at"`
}

PostM 是数据库中 post 记录 struct 格式的映射.

func (*PostM) AfterCreate

func (m *PostM) AfterCreate(tx *gorm.DB) error

AfterCreate 在创建数据库记录之后生成 postID.

func (*PostM) TableName

func (p *PostM) TableName() string

TableName 用来指定映射的 MySQL 表名.

type UserM

type UserM struct {
	ID        int64     `gorm:"column:id;primary_key"`
	UserID    string    `gorm:"column:user_id;not null"`
	Username  string    `gorm:"column:username;not null"`
	Password  string    `gorm:"column:password;not null"`
	Nickname  string    `gorm:"column:nickname"`
	Email     string    `gorm:"column:email"`
	Phone     string    `gorm:"column:phone"`
	CreatedAt time.Time `gorm:"column:created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at"`
}

UserM 是数据库中 user 记录 struct 格式的映射.

func (*UserM) AfterCreate

func (m *UserM) AfterCreate(tx *gorm.DB) error

AfterCreate 在创建数据库记录之后生成 userID.

func (*UserM) BeforeCreate

func (m *UserM) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate 在创建数据库记录之前加密明文密码.

func (*UserM) TableName

func (u *UserM) TableName() string

TableName 用来指定映射的 MySQL 表名.

Jump to

Keyboard shortcuts

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