changing field names

This commit is contained in:
2025-12-10 17:30:40 +00:00
parent 78a86b176f
commit d39d5c23c4
2 changed files with 19 additions and 17 deletions

View File

@@ -1,17 +1,18 @@
package models package models
import ( import (
"database/sql"
"time" "time"
"gorm.io/gorm"
) )
type Post struct { type Post struct {
ID uint `gorm:"primarykey" json:"id"` ID uint `gorm:"primarykey" json:"id"`
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"` UpdatedAt time.Time `json:"updatedAt"`
DeletedAt sql.NullTime `gorm:"index" json:"deletedAt"` DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt"`
Title string `gorm:"not null" json:"title"` Title string `gorm:"not null" json:"title"`
AuthorID uint `json:"-"` AuthorID uint `json:"-"`
Author *User `gorm:"foreignKey:AuthorID" json:"author"` Author *User `gorm:"foreignKey:AuthorID" json:"author"`
Content string `json:"content"` Content string `json:"content"`
} }

View File

@@ -1,16 +1,17 @@
package models package models
import ( import (
"database/sql"
"time" "time"
"gorm.io/gorm"
) )
type User struct { type User struct {
ID uint `gorm:"primarykey" json:"id"` ID uint `gorm:"primarykey" json:"id"`
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"` UpdatedAt time.Time `json:"updatedAt"`
DeletedAt sql.NullTime `gorm:"index" json:"deletedAt"` DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt"`
Username string `gorm:"uniqueIndex" json:"username"` Username string `gorm:"uniqueIndex" json:"username"`
Password []byte `json:"-"` Password []byte `json:"-"`
Admin bool `json:"admin"` Admin bool `json:"admin"`
} }