models

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OnlyTrashed

func OnlyTrashed(db *gorm.DB) *gorm.DB

OnlyTrashed returns a GORM scope that returns only soft-deleted records.

db.Scopes(models.OnlyTrashed).Find(&users)

func WithTrashed

func WithTrashed(db *gorm.DB) *gorm.DB

WithTrashed returns a GORM scope that includes soft-deleted records.

db.Scopes(models.WithTrashed).Find(&users)

Types

type BaseModel

type BaseModel struct {
	ID        uint           `gorm:"primaryKey" json:"id"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`
}

BaseModel provides common fields for all models. Embed this in your model structs to get ID, CreatedAt, UpdatedAt, and soft delete support via DeletedAt.

Jump to

Keyboard shortcuts

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