Documentation ¶
Index ¶
- Variables
- type Repositories
- func (r *Repositories) Create(target interface{}) error
- func (r *Repositories) CreateTx(target interface{}, tx *database.DB) error
- func (r *Repositories) DB() *database.DB
- func (r *Repositories) DBWithPreloads(preloads []string) *database.DB
- func (r *Repositories) Delete(target interface{}) error
- func (r *Repositories) DeleteTx(target interface{}, tx *database.DB) error
- func (r *Repositories) GetAll(target interface{}, preloads ...string) error
- func (r *Repositories) GetBatch(target interface{}, limit, offset int, preloads ...string) error
- func (r *Repositories) GetByField(target interface{}, field string, value interface{}, preloads ...string) error
- func (r *Repositories) GetByFieldBatch(target interface{}, field string, value interface{}, limit, offset int, ...) error
- func (r *Repositories) GetByFields(target interface{}, filters map[string]interface{}, preloads ...string) error
- func (r *Repositories) GetByFieldsBatch(target interface{}, filters map[string]interface{}, limit, offset int, ...) error
- func (r *Repositories) GetOneByField(target interface{}, field string, value interface{}, preloads ...string) error
- func (r *Repositories) GetOneByFields(target interface{}, filters map[string]interface{}, preloads ...string) error
- func (r *Repositories) GetOneByID(target interface{}, id string, preloads ...string) error
- func (r *Repositories) GetWhere(target interface{}, condition string, preloads ...string) error
- func (r *Repositories) GetWhereBatch(target interface{}, condition string, limit, offset int, preloads ...string) error
- func (r *Repositories) HandleError(res *database.DB) error
- func (r *Repositories) HandleOneError(res *database.DB) error
- func (r *Repositories) Save(target interface{}) error
- func (r *Repositories) SaveTx(target interface{}, tx *database.DB) error
- type Repository
- type TransactionRepository
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound is a convenience reference for the actual GORM error ErrNotFound = database.ErrRecordNotFound )
Functions ¶
This section is empty.
Types ¶
type Repositories ¶
type Repositories struct {
// contains filtered or unexported fields
}
func (*Repositories) Create ¶
func (r *Repositories) Create(target interface{}) error
func (*Repositories) CreateTx ¶
func (r *Repositories) CreateTx(target interface{}, tx *database.DB) error
func (*Repositories) DB ¶
func (r *Repositories) DB() *database.DB
func (*Repositories) DBWithPreloads ¶
func (r *Repositories) DBWithPreloads(preloads []string) *database.DB
func (*Repositories) Delete ¶
func (r *Repositories) Delete(target interface{}) error
func (*Repositories) DeleteTx ¶
func (r *Repositories) DeleteTx(target interface{}, tx *database.DB) error
func (*Repositories) GetAll ¶
func (r *Repositories) GetAll(target interface{}, preloads ...string) error
func (*Repositories) GetBatch ¶
func (r *Repositories) GetBatch(target interface{}, limit, offset int, preloads ...string) error
func (*Repositories) GetByField ¶
func (r *Repositories) GetByField(target interface{}, field string, value interface{}, preloads ...string) error
func (*Repositories) GetByFieldBatch ¶
func (r *Repositories) GetByFieldBatch(target interface{}, field string, value interface{}, limit, offset int, preloads ...string) error
func (*Repositories) GetByFields ¶
func (r *Repositories) GetByFields(target interface{}, filters map[string]interface{}, preloads ...string) error
func (*Repositories) GetByFieldsBatch ¶
func (r *Repositories) GetByFieldsBatch(target interface{}, filters map[string]interface{}, limit, offset int, preloads ...string) error
func (*Repositories) GetOneByField ¶
func (r *Repositories) GetOneByField(target interface{}, field string, value interface{}, preloads ...string) error
func (*Repositories) GetOneByFields ¶
func (r *Repositories) GetOneByFields(target interface{}, filters map[string]interface{}, preloads ...string) error
func (*Repositories) GetOneByID ¶
func (r *Repositories) GetOneByID(target interface{}, id string, preloads ...string) error
func (*Repositories) GetWhere ¶
func (r *Repositories) GetWhere(target interface{}, condition string, preloads ...string) error
func (*Repositories) GetWhereBatch ¶
func (r *Repositories) GetWhereBatch(target interface{}, condition string, limit, offset int, preloads ...string) error
func (*Repositories) HandleError ¶
func (r *Repositories) HandleError(res *database.DB) error
func (*Repositories) HandleOneError ¶
func (r *Repositories) HandleOneError(res *database.DB) error
func (*Repositories) Save ¶
func (r *Repositories) Save(target interface{}) error
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() *database.DB DBWithPreloads(preloads []string) *database.DB HandleError(res *database.DB) error HandleOneError(res *database.DB) error }
Repository is a generic DB handler that cares about default error handling
type TransactionRepository ¶
type TransactionRepository interface { Repository CreateTx(target interface{}, tx *database.DB) error SaveTx(target interface{}, tx *database.DB) error DeleteTx(target interface{}, tx *database.DB) error }
TransactionRepository extends Repository with modifier functions that accept a transaction
func NewRepositories ¶
func NewRepositories(ctx context.Context, db *database.DB, logger logger.Interface, defaultJoins ...string) TransactionRepository
NewRepositories returns a new base repositories that implements TransactionRepositories
Click to show internal directories.
Click to hide internal directories.