This commit is contained in:
2025-11-03 12:24:01 +02:00
commit 0806865287
177 changed files with 18453 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
package models
import (
"time"
"gorm.io/gorm"
)
type BaseModel struct {
ID ULID `gorm:"primaryKey" json:"id" db:"id" `
CreatedAt time.Time `json:"createdAt" db:"created_at"`
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
}
// BeforeCreate is a GORM hook that runs before creating a record
func (b *BaseModel) BeforeCreate(tx *gorm.DB) error {
if b.ID.IsZero() {
b.ID = GenerateULID()
}
return nil
}