Files
pocket-id-pocket-id-2/backend/internal/model/base.go
2024-08-23 17:04:19 +02:00

21 lines
328 B
Go

package model
import (
"github.com/google/uuid"
"gorm.io/gorm"
"time"
)
// Base contains common columns for all tables.
type Base struct {
ID string `gorm:"primaryKey;not null"`
CreatedAt time.Time
}
func (b *Base) BeforeCreate(_ *gorm.DB) (err error) {
if b.ID == "" {
b.ID = uuid.New().String()
}
return
}