models

package
v0.0.0-...-6643502 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseModel

type BaseModel struct {
	Id int `gorm:"primarykey"`

	CreatedAt time.Time `gorm:"type:TIMESTAMP with time zone;not null"`
}

func (*BaseModel) BeforeCreate

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

type Post

type Post struct {
	BaseModel
	Title    string `gorm:"type=string;size:256;not null";`
	Content  string `gorm:"type=text;not null"`
	User     User   `gorm:"foreignKey:AuthorId;constraint:OnUpdate:NO ACTION;OnDelete:NO ACTION"`
	AuthorId uint
}

type User

type User struct {
	BaseModel
	Username string `gorm:"type:string;size:50;not null;unique"`
	Email    string `gorm:"type:string;size:256;null;unique;default:null"`
	Password string `gorm:"type:string;size:256;not null"`
}

Jump to

Keyboard shortcuts

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