models

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseModel

type BaseModel struct {
	ID        uuid.UUID  `gorm:"type:uuid;primary_key" json:"id" validate:"required"`
	CreatedAt time.Time  `gorm:"autoCreateTime;not null" json:"created_at" validate:"required"`
	UpdatedAt time.Time  `gorm:"autoUpdateTime;not null" json:"updated_at" validate:"required"`
	DeletedAt *time.Time `gorm:"index" json:"deleted_at,omitempty"`
	CreatedBy *uuid.UUID `gorm:"type:uuid;index" json:"created_by,omitempty"`
	UpdatedBy *uuid.UUID `gorm:"type:uuid;index" json:"updated_by,omitempty"`
	DeletedBy *uuid.UUID `gorm:"type:uuid;index" json:"deleted_by,omitempty"`
}

BaseModel provides the foundation for all models with UUIDv7 primary key

func (*BaseModel) BeforeCreate

func (m *BaseModel) BeforeCreate(tx *gorm.DB) error

BeforeCreate is called before creating a new record

func (*BaseModel) BeforeDelete

func (m *BaseModel) BeforeDelete(tx *gorm.DB) error

BeforeDelete is called before deleting a record

func (*BaseModel) BeforeUpdate

func (m *BaseModel) BeforeUpdate(tx *gorm.DB) error

BeforeUpdate is called before updating a record

func (*BaseModel) GetCreatedAt

func (m *BaseModel) GetCreatedAt() time.Time

GetCreatedAt returns the creation timestamp

func (*BaseModel) GetCreatedBy

func (m *BaseModel) GetCreatedBy() uuid.UUID

GetCreatedBy returns the user who created the record

func (*BaseModel) GetDeletedAt

func (m *BaseModel) GetDeletedAt() *time.Time

GetDeletedAt returns the deletion timestamp

func (*BaseModel) GetDeletedBy

func (m *BaseModel) GetDeletedBy() uuid.UUID

GetDeletedBy returns the user who deleted the record

func (*BaseModel) GetID

func (m *BaseModel) GetID() uuid.UUID

GetID returns the model's ID

func (*BaseModel) GetUpdatedAt

func (m *BaseModel) GetUpdatedAt() time.Time

GetUpdatedAt returns the last update timestamp

func (*BaseModel) GetUpdatedBy

func (m *BaseModel) GetUpdatedBy() uuid.UUID

GetUpdatedBy returns the user who last updated the record

func (*BaseModel) IsDeleted

func (m *BaseModel) IsDeleted() bool

IsDeleted checks if the model is soft deleted

func (*BaseModel) Restore

func (m *BaseModel) Restore()

Restore restores a soft deleted model

func (*BaseModel) SetID

func (m *BaseModel) SetID(id uuid.UUID)

SetID sets the model's ID

type ModelFactory

type ModelFactory struct{}

ModelFactory provides factory methods for creating models

func (*ModelFactory) NewBaseModel

func (f *ModelFactory) NewBaseModel() *BaseModel

NewBaseModel creates a new BaseModel

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL