12 lines
351 B
Go
12 lines
351 B
Go
package models
|
|
|
|
import "gorm.io/gorm"
|
|
|
|
type Post struct {
|
|
gorm.Model // includes ID, CreatedAt, UpdatedAt, DeletedAt
|
|
Title string `gorm:"not null" json:"title"`
|
|
AuthorID uint `json:"-"`
|
|
Author User `gorm:"foreignKey:AuthorID,constraint:OnUpdate:CASCADE,OnDelete:SET NULL" json:"author"`
|
|
Content string `json:"content"`
|
|
}
|