implemented post handler

This commit is contained in:
2025-11-18 15:51:36 +00:00
parent fee7e26336
commit 32327afc70
5 changed files with 200 additions and 27 deletions

View File

@@ -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
}

View File

@@ -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
}