gormrepo

package
v1.1.12 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GenericRepository

type GenericRepository[T interface{}] interface {
	DB() *gorm.DB
	GetModel() T
	Debug() GenericRepository[T]
	Preload(query string, args ...interface{}) GenericRepository[T]
	All() ([]T, error)
	Create(ent T) (*T, error)
	Update(pk uint, ent T) (*T, error)
	Save(ent T) (*T, error)
	Find(pk uint) (*T, error)
	FindByEntity(ent T) (*T, error)
	FindByAttribute(attr string, value interface{}) (*T, error)
	Get(fn func(tx *gorm.DB) (*gorm.DB, error)) ([]T, error)
	GetByEntity(ent T) ([]T, error)
	GetByAttributes(attrs map[string]interface{}) ([]T, error)
	Delete(pk uint) (bool, error)
}

func NewGenericRepository

func NewGenericRepository[T interface{}](db *gorm.DB, model T) GenericRepository[T]

type Preload

type Preload struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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