Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterMigration ¶
func RegisterMigration(m *Migration)
RegisterMigration adds a migration to the database
func RegisterMigrations ¶
func RegisterMigrations(ms ...*Migration)
RegisterMigrations adds multiple migrations to the database
Types ¶
type BaseModel ¶
type BaseModel struct {
ID uuid.UUID `gorm:"primaryKey;type:uuid;default:uuid_generate_v4()"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt
}
BaseModel provides common fields for all models Models should embed this struct to get ID, timestamps, and soft delete support
type CRUDStore ¶
type CRUDStore[T any] struct { // contains filtered or unexported fields }
CRUDStore provides generic CRUD operations for any model type
func NewCRUDStore ¶
NewCRUDStore creates a new CRUD store for type T
type CRUDStoreInterface ¶
type CRUDStoreInterface[T any] interface { List(preloads ...string) ([]T, error) Get(id string, preloads ...string) (*T, error) Create(item T) error Update(item T) error Delete(id string) error }
CRUDStoreInterface defines the interface for CRUD operations
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database provides singleton access to GORM
type MigrationBuilder ¶
type MigrationBuilder struct {
// contains filtered or unexported fields
}
MigrationBuilder provides a fluent interface for building migrations
func NewMigrationBuilder ¶
func NewMigrationBuilder() *MigrationBuilder
NewMigrationBuilder creates a new MigrationBuilder instance
func (*MigrationBuilder) Build ¶
func (b *MigrationBuilder) Build() *Migration
Build constructs the final Migration
func (*MigrationBuilder) Deps ¶
func (b *MigrationBuilder) Deps(deps ...*Migration) *MigrationBuilder
Deps sets the dependencies for this migration
func (*MigrationBuilder) Model ¶
func (b *MigrationBuilder) Model(model interface{}) *MigrationBuilder
Model sets the model struct for this migration
func (*MigrationBuilder) Name ¶
func (b *MigrationBuilder) Name(name string) *MigrationBuilder
Name sets the name of this migration
type Polymorphic ¶
type Polymorphic struct {
OwnerID uuid.UUID `gorm:"type:uuid;index"`
OwnerType string `gorm:"index"`
}
Polymorphic provides fields for polymorphic relationships See: https://gorm.io/docs/polymorphism.html
Usage example:
type ChildModel struct {
model.Polymorphic `gorm:"embedded"`
Name string
}
type ParentModel struct {
Field ChildModel `gorm:"polymorphic:Owner;polymorphicValue:child_model;"`
}
type Seeder ¶
type Seeder struct {
// contains filtered or unexported fields
}
Seeder provides a framework for seeding test data