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 GetBatch(target interface{}, limit, offset int, preloads ...string) error GetWhere(target interface{}, condition string, preloads ...string) error GetWhereBatch(target interface{}, condition string, limit, offset int, preloads ...string) error GetByField(target interface{}, field string, value interface{}, preloads ...string) error GetByFields(target interface{}, filters map[string]interface{}, preloads ...string) error GetByFieldBatch(target interface{}, field string, value interface{}, limit, offset int, preloads ...string) error GetByFieldsBatch(target interface{}, filters map[string]interface{}, limit, offset int, preloads ...string) error GetOneByField(target interface{}, field string, value interface{}, preloads ...string) error GetOneByFields(target interface{}, filters map[string]interface{}, preloads ...string) error // GetOneByID assumes you have a PK column "id" which is a UUID. If this is not the case just ignore the method // and add a custom struct with this Repository embedded. 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.