adding gorm
This commit is contained in:
11
backend/models/post.go
Normal file
11
backend/models/post.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package models
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type Post struct {
|
||||
gorm.Model // includes ID, CreatedAt, UpdatedAt, DeletedAt
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user