worktime/internal/database/models/base.go
2025-11-07 13:40:22 +01:00

20 lines
435 B
Go

package models
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
type Base struct {
ID string `gorm:"column:id;<-:create;type:uuid;primaryKey;unique" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
}
func (b *Base) BeforeCreate(tx *gorm.DB) (err error) {
b.ID = uuid.NewString()
return
}