Added BeforeSave
This commit is contained in:
parent
567470372f
commit
db89056468
@ -2,6 +2,8 @@ package models
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DBParticipant struct {
|
type DBParticipant struct {
|
||||||
@ -30,3 +32,11 @@ type DBParticipant struct {
|
|||||||
func (DBParticipant) TableName() string {
|
func (DBParticipant) TableName() string {
|
||||||
return "gc_participants"
|
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
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user