machinelock-manager/db/base.go
2024-12-27 23:47:52 +01:00

20 lines
346 B
Go

package db
import (
"time"
uuid "github.com/satori/go.uuid"
"gorm.io/gorm"
)
type Base struct {
ID *uuid.UUID `gorm:"type:uuid;primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (b *Base) BeforeCreate(_ *gorm.DB) error {
id := uuid.NewV4()
b.ID = &id
return nil
}