Files
kontor/kontor-gin/pkg/schema/base.go
T
Thomas Peetz 8f5a384e89
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
add subproject kontor-gin
2026-09-18 17:42:50 +02:00

23 lines
500 B
Go

package schema
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
type Base struct {
ID string `gorm:"type:string;primary_key;"`
CreatedAt time.Time `json:"created_date"`
UpdatedAt time.Time `json:"last_modified_date"`
DeletedAt *time.Time `json:"deleted_date"`
Version int `gorm:"default:0" json:"version"`
}
// BeforeCreate will set a UUID rather than numeric ID.
func (b *Base) BeforeCreate(tx *gorm.DB) (err error) {
b.ID = uuid.New().String()
return
}