mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-08-31 16:21:26 +02:00
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)
24 lines
467 B
Go
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
|
|
}
|