Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound is a convenience reference for the actual GORM error ErrNotFound = gorm.ErrRecordNotFound )
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository interface { GetAll(target interface{}, preloads ...string) error GetByField(target interface{}, field string, value interface{}, preloads ...string) error GetByFields(target interface{}, filters map[string]interface{}, preloads ...string) error GetOneByField(target interface{}, field string, value interface{}, preloads ...string) error GetOneByFields(target interface{}, filters map[string]interface{}, preloads ...string) error GetOneByID(target interface{}, id string, preloads ...string) error Create(target interface{}) error Save(target interface{}) error Delete(target interface{}) error DB() *gorm.DB DBWithPreloads(preloads []string) *gorm.DB HandleError(res *gorm.DB) error HandleOneError(res *gorm.DB) error }
Repository is a generic DB handler that cares about default error handling
type TransactionRepository ¶
type TransactionRepository interface { Repository CreateTx(target interface{}, tx *gorm.DB) error SaveTx(target interface{}, tx *gorm.DB) error DeleteTx(target interface{}, tx *gorm.DB) error }
TransactionRepository extends Repository with modifier functions that accept a transaction
func NewGormRepository ¶
func NewGormRepository(db *gorm.DB, logger logging.Logger, defaultJoins ...string) TransactionRepository
NewGormRepository returns a new base repository that implements TransactionRepository
Click to show internal directories.
Click to hide internal directories.