Files
pocket-id/backend/internal/model/base.go
ItalyPaleAle 0c79ae0ea6 chore: update Francis to rc.2
Also replaces the direct use of the github.com/google/uuid package with the uuid package from the standard library in Go 1.27 (package remains as a transitive dep)
2026-08-31 07:47:09 +02:00

24 lines
467 B
Go

package model
import (
"time"
"uuid"
datatype "github.com/pocket-id/pocket-id/backend/internal/model/types"
"gorm.io/gorm"
)
// Base contains common columns for all tables.
type Base struct {
ID string `gorm:"primaryKey;not null"`
CreatedAt datatype.DateTime `sortable:"true"`
}
func (b *Base) BeforeCreate(_ *gorm.DB) (err error) {
if b.ID == "" {
b.ID = uuid.NewV4().String()
}
b.CreatedAt = datatype.DateTime(time.Now())
return
}