diff --git a/backend/models/post.go b/backend/models/post.go index aa1bbf8..50f33ab 100644 --- a/backend/models/post.go +++ b/backend/models/post.go @@ -1,17 +1,18 @@ package models import ( - "database/sql" "time" + + "gorm.io/gorm" ) type Post struct { - ID uint `gorm:"primarykey" json:"id"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - DeletedAt sql.NullTime `gorm:"index" json:"deletedAt"` - Title string `gorm:"not null" json:"title"` - AuthorID uint `json:"-"` - Author *User `gorm:"foreignKey:AuthorID" json:"author"` - Content string `json:"content"` + ID uint `gorm:"primarykey" json:"id"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt"` + Title string `gorm:"not null" json:"title"` + AuthorID uint `json:"-"` + Author *User `gorm:"foreignKey:AuthorID" json:"author"` + Content string `json:"content"` } diff --git a/backend/models/user.go b/backend/models/user.go index 2f925fe..a7dac57 100644 --- a/backend/models/user.go +++ b/backend/models/user.go @@ -1,16 +1,17 @@ package models import ( - "database/sql" "time" + + "gorm.io/gorm" ) type User struct { - ID uint `gorm:"primarykey" json:"id"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - DeletedAt sql.NullTime `gorm:"index" json:"deletedAt"` - Username string `gorm:"uniqueIndex" json:"username"` - Password []byte `json:"-"` - Admin bool `json:"admin"` + ID uint `gorm:"primarykey" json:"id"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt"` + Username string `gorm:"uniqueIndex" json:"username"` + Password []byte `json:"-"` + Admin bool `json:"admin"` }