Documentation
¶
Index ¶
- type BaseModel
- func (m *BaseModel) BeforeCreate(tx *gorm.DB) error
- func (m *BaseModel) BeforeDelete(tx *gorm.DB) error
- func (m *BaseModel) BeforeUpdate(tx *gorm.DB) error
- func (m *BaseModel) GetCreatedAt() time.Time
- func (m *BaseModel) GetCreatedBy() uuid.UUID
- func (m *BaseModel) GetDeletedAt() *time.Time
- func (m *BaseModel) GetDeletedBy() uuid.UUID
- func (m *BaseModel) GetID() uuid.UUID
- func (m *BaseModel) GetUpdatedAt() time.Time
- func (m *BaseModel) GetUpdatedBy() uuid.UUID
- func (m *BaseModel) IsDeleted() bool
- func (m *BaseModel) Restore()
- func (m *BaseModel) SetID(id uuid.UUID)
- type ModelFactory
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 ¶
BeforeCreate is called before creating a new record
func (*BaseModel) BeforeDelete ¶
BeforeDelete is called before deleting a record
func (*BaseModel) BeforeUpdate ¶
BeforeUpdate is called before updating a record
func (*BaseModel) GetCreatedAt ¶
GetCreatedAt returns the creation timestamp
func (*BaseModel) GetCreatedBy ¶
GetCreatedBy returns the user who created the record
func (*BaseModel) GetDeletedAt ¶
GetDeletedAt returns the deletion timestamp
func (*BaseModel) GetDeletedBy ¶
GetDeletedBy returns the user who deleted the record
func (*BaseModel) GetUpdatedAt ¶
GetUpdatedAt returns the last update timestamp
func (*BaseModel) GetUpdatedBy ¶
GetUpdatedBy returns the user who last updated the record
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
Click to show internal directories.
Click to hide internal directories.