- Create models/user.go with bcrypt password hashing - Create models/user_profile.go with foreign key relationship - Add GORM hooks for automatic profile creation - Include proper JSON tags and database constraints
12 lines
465 B
Go
12 lines
465 B
Go
package models
|
|
|
|
type UserProfile struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
UserID uint `gorm:"not null" json:"user_id"`
|
|
FirstName string `gorm:"size:80;not null" json:"first_name"`
|
|
LastName string `gorm:"size:80;not null" json:"last_name"`
|
|
Bio string `gorm:"type:text" json:"bio"`
|
|
ProfilePicture string `gorm:"size:255" json:"profile_picture"`
|
|
|
|
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
|
|
}
|