Documentation ¶
Index ¶
- func Contains(arr []string, str string) bool
- func ContainsKey(keyValuePair map[string][]string, keyToCheck string) bool
- func DoesColumnExistInTable(uow *UnitOfWork, tableName string, ColumnName string) bool
- type GormRepository
- func (repository *GormRepository) Add(uow *UnitOfWork, entity interface{}) microappError.DatabaseError
- func (repository *GormRepository) AddAssociations(uow *UnitOfWork, out interface{}, associationName string, ...) microappError.DatabaseError
- func (repository *GormRepository) Delete(uow *UnitOfWork, entity interface{}, where ...interface{}) microappError.DatabaseError
- func (repository *GormRepository) DeleteForTenant(uow *UnitOfWork, entity interface{}, tenantID uuid.UUID) microappError.DatabaseError
- func (repository *GormRepository) DeletePermanent(uow *UnitOfWork, entity interface{}, where ...interface{}) microappError.DatabaseError
- func (repository *GormRepository) Get(uow *UnitOfWork, out interface{}, id uuid.UUID, preloadAssociations []string) microappError.DatabaseError
- func (repository *GormRepository) GetAll(uow *UnitOfWork, out interface{}, queryProcessors []QueryProcessor) microappError.DatabaseError
- func (repository *GormRepository) GetAllForTenant(uow *UnitOfWork, out interface{}, tenantID uuid.UUID, ...) microappError.DatabaseError
- func (repository *GormRepository) GetAllUnscoped(uow *UnitOfWork, out interface{}, queryProcessors []QueryProcessor) microappError.DatabaseError
- func (repository *GormRepository) GetAllUnscopedForTenant(uow *UnitOfWork, out interface{}, tenantID uuid.UUID, ...) microappError.DatabaseError
- func (repository *GormRepository) GetCount(uow *UnitOfWork, count *int, entity interface{}, ...) microappError.DatabaseError
- func (repository *GormRepository) GetCountForTenant(uow *UnitOfWork, count *int, tenantID uuid.UUID, entity interface{}, ...) microappError.DatabaseError
- func (repository *GormRepository) GetFirst(uow *UnitOfWork, out interface{}, queryProcessors []QueryProcessor) microappError.DatabaseError
- func (repository *GormRepository) GetForTenant(uow *UnitOfWork, out interface{}, id string, tenantID uuid.UUID, ...) microappError.DatabaseError
- func (repository *GormRepository) RemoveAssociations(uow *UnitOfWork, out interface{}, associationName string, ...) microappError.DatabaseError
- func (repository *GormRepository) ReplaceAssociations(uow *UnitOfWork, out interface{}, associationName string, ...) microappError.DatabaseError
- func (repository *GormRepository) Update(uow *UnitOfWork, entity interface{}) microappError.DatabaseError
- type QueryProcessor
- func AddFiltersFromQueryParams(r *http.Request, filterDetails ...string) ([]QueryProcessor, error)
- func AddFiltersFromQueryParamsWithOR(r *http.Request, filterDetails ...string) ([]QueryProcessor, error)
- func Filter(condition string, args ...interface{}) QueryProcessor
- func FilterWithOR(columnName []string, condition []string, filterValues []interface{}) QueryProcessor
- func GetOrderBy(orderByAttrs []string, validOrderByAttrs []string, ...) (QueryProcessor, error)
- func Order(value interface{}, reorder bool) QueryProcessor
- func Paginate(limit int, offset int, count *int) QueryProcessor
- func PaginateForWeb(w http.ResponseWriter, r *http.Request) QueryProcessor
- func PreloadAssociations(preloadAssociations []string) QueryProcessor
- func TimeRangeForWeb(r *http.Request, fieldName string) QueryProcessor
- type Repository
- type UnitOfWork
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsKey ¶ added in v0.0.84
ContainsKey checks if key present in map
func DoesColumnExistInTable ¶ added in v0.0.84
func DoesColumnExistInTable(uow *UnitOfWork, tableName string, ColumnName string) bool
DoesColumnExistInTable returns bool if the column exist in table
Types ¶
type GormRepository ¶
type GormRepository struct { }
GormRepository implements Repository
func (*GormRepository) Add ¶
func (repository *GormRepository) Add(uow *UnitOfWork, entity interface{}) microappError.DatabaseError
Add specified Entity
func (*GormRepository) AddAssociations ¶ added in v0.0.103
func (repository *GormRepository) AddAssociations(uow *UnitOfWork, out interface{}, associationName string, associations ...interface{}) microappError.DatabaseError
AddAssociations adds associations to the given out entity
func (*GormRepository) Delete ¶
func (repository *GormRepository) Delete(uow *UnitOfWork, entity interface{}, where ...interface{}) microappError.DatabaseError
Delete specified Entity
func (*GormRepository) DeleteForTenant ¶ added in v0.0.113
func (repository *GormRepository) DeleteForTenant(uow *UnitOfWork, entity interface{}, tenantID uuid.UUID) microappError.DatabaseError
DeleteForTenant all recrod(s) of specified entity / entity type for given tenant
func (*GormRepository) DeletePermanent ¶ added in v1.0.8
func (repository *GormRepository) DeletePermanent(uow *UnitOfWork, entity interface{}, where ...interface{}) microappError.DatabaseError
DeletePermanent deletes record permanently specified Entity
func (*GormRepository) Get ¶
func (repository *GormRepository) Get(uow *UnitOfWork, out interface{}, id uuid.UUID, preloadAssociations []string) microappError.DatabaseError
Get a record for specified entity with specific id
func (*GormRepository) GetAll ¶
func (repository *GormRepository) GetAll(uow *UnitOfWork, out interface{}, queryProcessors []QueryProcessor) microappError.DatabaseError
GetAll retrieves all the records for a specified entity and returns it
func (*GormRepository) GetAllForTenant ¶ added in v0.0.6
func (repository *GormRepository) GetAllForTenant(uow *UnitOfWork, out interface{}, tenantID uuid.UUID, queryProcessors []QueryProcessor) microappError.DatabaseError
GetAllForTenant returns all objects of specifeid tenantID
func (*GormRepository) GetAllUnscoped ¶ added in v1.0.4
func (repository *GormRepository) GetAllUnscoped(uow *UnitOfWork, out interface{}, queryProcessors []QueryProcessor) microappError.DatabaseError
GetAllUnscoped retrieves all the records (including deleted) for a specified entity and returns it
func (*GormRepository) GetAllUnscopedForTenant ¶ added in v1.0.4
func (repository *GormRepository) GetAllUnscopedForTenant(uow *UnitOfWork, out interface{}, tenantID uuid.UUID, queryProcessors []QueryProcessor) microappError.DatabaseError
GetAllUnscopedForTenant returns all objects (including deleted) of specifeid tenantID
func (*GormRepository) GetCount ¶ added in v1.0.7
func (repository *GormRepository) GetCount(uow *UnitOfWork, count *int, entity interface{}, queryProcessors []QueryProcessor) microappError.DatabaseError
GetCount gets count of the given entity type
func (*GormRepository) GetCountForTenant ¶ added in v0.0.96
func (repository *GormRepository) GetCountForTenant(uow *UnitOfWork, count *int, tenantID uuid.UUID, entity interface{}, queryProcessors []QueryProcessor) microappError.DatabaseError
GetCountForTenant gets count of the given entity type for specified tenant
func (*GormRepository) GetFirst ¶ added in v1.0.0
func (repository *GormRepository) GetFirst(uow *UnitOfWork, out interface{}, queryProcessors []QueryProcessor) microappError.DatabaseError
GetFirst gets first record matching the given criteria
func (*GormRepository) GetForTenant ¶ added in v0.0.98
func (repository *GormRepository) GetForTenant(uow *UnitOfWork, out interface{}, id string, tenantID uuid.UUID, preloadAssociations []string) microappError.DatabaseError
GetForTenant a record for specified entity with specific id and for specified tenant
func (*GormRepository) RemoveAssociations ¶ added in v0.0.105
func (repository *GormRepository) RemoveAssociations(uow *UnitOfWork, out interface{}, associationName string, associations ...interface{}) microappError.DatabaseError
RemoveAssociations removes associations from the given out entity
func (*GormRepository) ReplaceAssociations ¶ added in v0.0.105
func (repository *GormRepository) ReplaceAssociations(uow *UnitOfWork, out interface{}, associationName string, associations ...interface{}) microappError.DatabaseError
ReplaceAssociations removes associations from the given out entity
func (*GormRepository) Update ¶
func (repository *GormRepository) Update(uow *UnitOfWork, entity interface{}) microappError.DatabaseError
Update specified Entity
type QueryProcessor ¶ added in v0.0.23
type QueryProcessor func(db *gorm.DB, out interface{}) (*gorm.DB, microappError.DatabaseError)
QueryProcessor allows to modify the query before it is executed
func AddFiltersFromQueryParams ¶ added in v0.0.78
func AddFiltersFromQueryParams(r *http.Request, filterDetails ...string) ([]QueryProcessor, error)
AddFiltersFromQueryParams will check for given filter(s) in the query params, if value found creates the db filter. filterDetail format - "filterName[:type]".
func AddFiltersFromQueryParamsWithOR ¶ added in v0.0.82
func AddFiltersFromQueryParamsWithOR(r *http.Request, filterDetails ...string) ([]QueryProcessor, error)
AddFiltersFromQueryParamsWithOR will check for given filter(s) in the query params, if value found adds it in array and creates the db filter. filterDetail format - "filterName[:type]". Same field Filters are using 'OR' , 'AND' would be done between different fields
func Filter ¶ added in v0.0.23
func Filter(condition string, args ...interface{}) QueryProcessor
Filter will filter the results
func FilterWithOR ¶ added in v0.0.81
func FilterWithOR(columnName []string, condition []string, filterValues []interface{}) QueryProcessor
FilterWithOR will filter the results with an 'OR'
func GetOrderBy ¶ added in v0.0.110
func GetOrderBy(orderByAttrs []string, validOrderByAttrs []string, orderByAttrAndDBCloum map[string][]string, reorder bool) (QueryProcessor, error)
GetOrderBy creates order by query processor orderByAttrs - ["column1:0", "column2:1"], validOrderByAttrs - ["column1", "column2", "column3"], orderByAttrAndDBCloum - {"cloumn3": ["dbColunm4", "dbColumn5"]}
func Order ¶ added in v0.0.76
func Order(value interface{}, reorder bool) QueryProcessor
Order will order the results
func Paginate ¶ added in v0.0.23
func Paginate(limit int, offset int, count *int) QueryProcessor
Paginate will restrict the output of query
func PaginateForWeb ¶ added in v0.0.26
func PaginateForWeb(w http.ResponseWriter, r *http.Request) QueryProcessor
PaginateForWeb will take limit and offset parameters from URL and will set X-Total-Count header in response
func PreloadAssociations ¶ added in v0.0.23
func PreloadAssociations(preloadAssociations []string) QueryProcessor
PreloadAssociations specified associations to be preloaded
func TimeRangeForWeb ¶ added in v0.0.42
func TimeRangeForWeb(r *http.Request, fieldName string) QueryProcessor
TimeRangeForWeb will take limit and offset parameters from URL and will set X-Total-Count header in response
type Repository ¶
type Repository interface { Get(uow *UnitOfWork, out interface{}, id uuid.UUID, preloadAssociations []string) microappError.DatabaseError GetFirst(uow *UnitOfWork, out interface{}, queryProcessors []QueryProcessor) microappError.DatabaseError GetForTenant(uow *UnitOfWork, out interface{}, id string, tenantID uuid.UUID, preloadAssociations []string) microappError.DatabaseError GetAll(uow *UnitOfWork, out interface{}, queryProcessors []QueryProcessor) microappError.DatabaseError GetAllForTenant(uow *UnitOfWork, out interface{}, tenantID uuid.UUID, queryProcessors []QueryProcessor) microappError.DatabaseError GetAllUnscoped(uow *UnitOfWork, out interface{}, queryProcessors []QueryProcessor) microappError.DatabaseError GetAllUnscopedForTenant(uow *UnitOfWork, out interface{}, tenantID uuid.UUID, queryProcessors []QueryProcessor) microappError.DatabaseError GetCount(uow *UnitOfWork, out *int, entity interface{}, queryProcessors []QueryProcessor) microappError.DatabaseError GetCountForTenant(uow *UnitOfWork, out *int, tenantID uuid.UUID, entity interface{}, queryProcessors []QueryProcessor) microappError.DatabaseError Add(uow *UnitOfWork, out interface{}) microappError.DatabaseError Update(uow *UnitOfWork, out interface{}) microappError.DatabaseError Delete(uow *UnitOfWork, out interface{}, where ...interface{}) microappError.DatabaseError DeleteForTenant(uow *UnitOfWork, out interface{}, tenantID uuid.UUID) microappError.DatabaseError DeletePermanent(uow *UnitOfWork, out interface{}, where ...interface{}) microappError.DatabaseError AddAssociations(uow *UnitOfWork, out interface{}, associationName string, associations ...interface{}) microappError.DatabaseError RemoveAssociations(uow *UnitOfWork, out interface{}, associationName string, associations ...interface{}) microappError.DatabaseError ReplaceAssociations(uow *UnitOfWork, out interface{}, associationName string, associations ...interface{}) microappError.DatabaseError }
Repository represents generic interface for interacting with DB
type UnitOfWork ¶
UnitOfWork represents a connection
func NewUnitOfWork ¶
func NewUnitOfWork(db *gorm.DB, readOnly bool) *UnitOfWork
NewUnitOfWork creates new UnitOfWork