init
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// #[derive(Debug, Clone, sqlx::FromRow, Serialize, Deserialize)]
|
||||
@@ -48,3 +49,10 @@ type Channel struct {
|
||||
Server *Server `gorm:"foreignKey:ServerID" json:"server,omitempty"`
|
||||
Category *Category `gorm:"foreignKey:CategoryID" json:"category,omitempty"`
|
||||
}
|
||||
|
||||
func (s *Channel) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
if s.ID == uuid.Nil {
|
||||
s.ID = uuid.New()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user