Compare commits

...

2 Commits

Author SHA1 Message Date
db89056468 Added BeforeSave 2025-10-23 17:02:52 +11:00
567470372f askilhdfjasdgf 2025-10-23 16:59:06 +11:00
2 changed files with 11 additions and 1 deletions

View File

@@ -192,7 +192,7 @@ type UsersQuery struct {
}
type GCUser struct {
Id string `json:"id" gorm:"primaryKey;foreignKey"`
Id string `json:"id" gorm:"primaryKey"`
Name string `json:"name"`
Email string `json:"email"`
State string `json:"state"`

View File

@@ -2,6 +2,8 @@ package models
import (
"time"
"gorm.io/gorm"
)
type DBParticipant struct {
@@ -30,3 +32,11 @@ type DBParticipant struct {
func (DBParticipant) TableName() string {
return "gc_participants"
}
func (p *DBParticipant) BeforeSave(tx *gorm.DB) error {
// Convert empty string to nil
if p.UserId != nil && *p.UserId == "" {
p.UserId = nil
}
return nil
}