implemented post handler
This commit is contained in:
@@ -7,5 +7,4 @@ type Post struct {
|
||||
Title string `gorm:"not null"`
|
||||
Content string `gorm:"type:text; not null"`
|
||||
AuthorID uint // foreign key to User
|
||||
Author User `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"` // optional relation
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package models
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type User struct {
|
||||
gorm.Model // includes ID, CreatedAt, UpdatedAt, DeletedAt
|
||||
Name string
|
||||
gorm.Model // includes ID, CreatedAt, UpdatedAt, DeletedAt
|
||||
Name string `gorm:"uniqueIndex"`
|
||||
Email string `gorm:"uniqueIndex"`
|
||||
Password string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user