Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| db89056468 | |||
| 567470372f | |||
| 674f7dd5f5 | |||
| f50333d223 |
@@ -192,7 +192,7 @@ type UsersQuery struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GCUser struct {
|
type GCUser struct {
|
||||||
Id string `json:"id" gorm:"primaryKey;foreignKey"`
|
Id string `json:"id" gorm:"primaryKey"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
State string `json:"state"`
|
State string `json:"state"`
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package models
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DBParticipant struct {
|
type DBParticipant struct {
|
||||||
@@ -24,9 +26,17 @@ type DBParticipant struct {
|
|||||||
|
|
||||||
Sessions []DBSession `gorm:"foreignKey:ParticipantId;references:Id"`
|
Sessions []DBSession `gorm:"foreignKey:ParticipantId;references:Id"`
|
||||||
Calls []DBCall `gorm:"foreignKey:ParticipantId;references:Id"`
|
Calls []DBCall `gorm:"foreignKey:ParticipantId;references:Id"`
|
||||||
User GCUser `gorm:"foreignKey:UserId;references:Id`
|
User *GCUser `gorm:"foreignKey:UserId;references:Id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user