Documentation ¶
Index ¶
- type GormRepository
- func (r GormRepository) AutoMigrateOrWarn(models ...interface{})
- func (r GormRepository) Count(model, query interface{}, args ...interface{}) (count int64, err error)
- func (r *GormRepository) Create(target interface{}) error
- func (r *GormRepository) CreateTx(target interface{}, tx *gorm.DB) error
- func (r *GormRepository) DB() *gorm.DB
- func (r *GormRepository) DBWithPreloads(preloads []string) *gorm.DB
- func (r *GormRepository) Delete(target interface{}) error
- func (r *GormRepository) DeleteTx(target interface{}, tx *gorm.DB) error
- func (r GormRepository) FindPage(page, perPage uint, query *gorm.DB, out interface{}) (Page, error)
- func (r *GormRepository) GetAll(target interface{}, preloads ...string) error
- func (r *GormRepository) GetByField(target interface{}, field string, value interface{}, preloads ...string) error
- func (r *GormRepository) GetByFields(target interface{}, filters map[string]interface{}, preloads ...string) error
- func (r *GormRepository) GetOneByField(target interface{}, field string, value interface{}, preloads ...string) error
- func (r *GormRepository) GetOneByFields(target interface{}, filters map[string]interface{}, preloads ...string) error
- func (r *GormRepository) GetOneByID(target interface{}, id string, preloads ...string) error
- func (r *GormRepository) GetWhere(target interface{}, condition string, preloads ...string) error
- func (r *GormRepository) HandleError(res *gorm.DB) error
- func (r *GormRepository) HandleOneError(res *gorm.DB) error
- func (r *GormRepository) Save(target interface{}) error
- func (r *GormRepository) SaveTx(target interface{}, tx *gorm.DB) error
- type Page
- type Repository
- type TransactionRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GormRepository ¶
type GormRepository struct {
// contains filtered or unexported fields
}
func (GormRepository) AutoMigrateOrWarn ¶
func (r GormRepository) AutoMigrateOrWarn(models ...interface{})
AutoMigrateOrWarn create tables for the given models or print a warning message if there's an error
func (GormRepository) Count ¶
func (r GormRepository) Count(model, query interface{}, args ...interface{}) (count int64, err error)
Count count total number of records for the given query
func (*GormRepository) Create ¶
func (r *GormRepository) Create(target interface{}) error
func (*GormRepository) CreateTx ¶
func (r *GormRepository) CreateTx(target interface{}, tx *gorm.DB) error
func (*GormRepository) DB ¶
func (r *GormRepository) DB() *gorm.DB
func (*GormRepository) DBWithPreloads ¶
func (r *GormRepository) DBWithPreloads(preloads []string) *gorm.DB
func (*GormRepository) Delete ¶
func (r *GormRepository) Delete(target interface{}) error
func (*GormRepository) DeleteTx ¶
func (r *GormRepository) DeleteTx(target interface{}, tx *gorm.DB) error
func (*GormRepository) GetAll ¶
func (r *GormRepository) GetAll(target interface{}, preloads ...string) error
func (*GormRepository) GetByField ¶
func (r *GormRepository) GetByField(target interface{}, field string, value interface{}, preloads ...string) error
func (*GormRepository) GetByFields ¶
func (r *GormRepository) GetByFields(target interface{}, filters map[string]interface{}, preloads ...string) error
func (*GormRepository) GetOneByField ¶
func (r *GormRepository) GetOneByField(target interface{}, field string, value interface{}, preloads ...string) error
func (*GormRepository) GetOneByFields ¶
func (r *GormRepository) GetOneByFields(target interface{}, filters map[string]interface{}, preloads ...string) error
func (*GormRepository) GetOneByID ¶
func (r *GormRepository) GetOneByID(target interface{}, id string, preloads ...string) error
func (*GormRepository) GetWhere ¶
func (r *GormRepository) GetWhere(target interface{}, condition string, preloads ...string) error
func (*GormRepository) HandleError ¶
func (r *GormRepository) HandleError(res *gorm.DB) error
func (*GormRepository) HandleOneError ¶
func (r *GormRepository) HandleOneError(res *gorm.DB) error
func (*GormRepository) Save ¶
func (r *GormRepository) Save(target interface{}) error
type Repository ¶
type Repository interface { GetAll(target interface{}, preloads ...string) error GetWhere(target interface{}, condition string, 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 FindPage(page, perPage uint, query *gorm.DB, out interface{}) (Page, error) Count(model, query interface{}, args ...interface{}) (count int64, err error) DB() *gorm.DB DBWithPreloads(preloads []string) *gorm.DB HandleError(res *gorm.DB) error HandleOneError(res *gorm.DB) error AutoMigrateOrWarn(models ...interface{}) }
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 *glog.Logger, defaultJoins ...string) TransactionRepository
NewGormRepository returns a new base repository that implements TransactionRepository
Click to show internal directories.
Click to hide internal directories.