init
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Attachment struct {
|
||||
@@ -17,3 +18,10 @@ type Attachment struct {
|
||||
// Relation optionnelle vers le message
|
||||
Message *Message `gorm:"foreignKey:MessageID" json:"message,omitempty"`
|
||||
}
|
||||
|
||||
func (s *Attachment) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
if s.ID == uuid.Nil {
|
||||
s.ID = uuid.New()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user