model

package
v0.0.0-...-d6508de Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category struct {
	ID    uint   `gorm:"primary_key:auto_increment" json:"id"`
	Name  string `gorm:"type:varchar(100)" json:"name"`
	Posts []Post `json:"posts"`
}

type Comment

type Comment struct {
	gorm.Model
	Body   string `gorm:"type:varchar(150)" json:"body"`
	UserID uint
	PostID uint
}

type Post

type Post struct {
	gorm.Model
	Title       string    `gorm:"type:varchar(100)" json:"title"`
	Description string    `gorm:"type:text" json:"description"`
	Image       string    `gorm:"type:varchar(255)" json:"image"`
	CategoryID  uint      `json:"category"`
	Category    Category  `gorm:"foreignkey:CategoryID" json:"-"`
	Comments    []Comment `json:"comments"`
}

type User

type User struct {
	ID       uint64    `gorm:"primary_key:auto_increment" json:"id"`
	Name     string    `gorm:"type:varchar(255)" json:"name"`
	Email    string    `gorm:"uniqueIndex;type:varchar(255)" json:"email"`
	Password string    `gorm:"not null" json:"-"`
	Comments []Comment `json:"-"`
}

Jump to

Keyboard shortcuts

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