Documentation ¶
Index ¶
- Variables
- func CrudRoutes(models Validation, freq func(r *http.Request, req *gorm.DB) *gorm.DB, ...) utils.Routes
- func CrudRoutesSpecificURL(models Validation, freq func(r *http.Request, req *gorm.DB) *gorm.DB, ...) utils.Routes
- func DefaultQueryAll(r *http.Request, req *gorm.DB) *gorm.DB
- func DefaultRightAccess(r *http.Request, data interface{}) bool
- func DefaultRightEdit(r *http.Request, data interface{}, data2 interface{}) bool
- func DeleteAssociation(tx *gorm.DB, parent Validation, dataType Validation, associationName string, ...)
- func GenericCreate(w http.ResponseWriter, r *http.Request, data Validation, ...)
- func GenericDelete(w http.ResponseWriter, r *http.Request, data Validation, ...)
- func GenericGet(w http.ResponseWriter, r *http.Request, data Validation, ...)
- func GenericGetQueryAll(w http.ResponseWriter, r *http.Request, data Validation, ...)
- func GenericUpdate(w http.ResponseWriter, r *http.Request, data Validation, ...)
- func GetAllFromDb(r *http.Request) (int, int, string)
- func GetDB() *gorm.DB
- func GetFromID(r *http.Request, data Validation, preloads ...string) error
- func GetQuery(r *http.Request, req *gorm.DB, columns map[string]string) *gorm.DB
- func SetDB(initDB *gorm.DB)
- type Authed
- type HistoryAble
- type Validation
Constants ¶
This section is empty.
Variables ¶
var DefaultCountFunc = func(r *http.Request, req *gorm.DB) (int64, map[string]interface{}, error) { resp := utils.Message(true, "data returned") count := int64(0) req.Count(&count) return count, resp, nil }
var DefaultQueryFilteringFunc = func(r *http.Request, req *gorm.DB, key string, value []string) *gorm.DB {
switch key {
default:
req = req.Where(key+" IN (?)", value)
}
return req
}
Add some specific filtering stuff depending on object fields
Functions ¶
func CrudRoutes ¶
func CrudRoutes(models Validation, freq func(r *http.Request, req *gorm.DB) *gorm.DB, getallrights utils.RightBits, getfunc func(r *http.Request, data interface{}) bool, getrights utils.RightBits, crefunc func(r *http.Request, data interface{}) bool, crerights utils.RightBits, updfunc func(r *http.Request, data interface{}, data2 interface{}) bool, updrights utils.RightBits, delfunc func(r *http.Request, data interface{}) bool, delrights utils.RightBits) utils.Routes
CrudRoutes Generate default CRUD route for object
func CrudRoutesSpecificURL ¶
func CrudRoutesSpecificURL(models Validation, freq func(r *http.Request, req *gorm.DB) *gorm.DB, getallrights utils.RightBits, getfunc func(r *http.Request, data interface{}) bool, getrights utils.RightBits, crefunc func(r *http.Request, data interface{}) bool, crerights utils.RightBits, updfunc func(r *http.Request, data interface{}, data2 interface{}) bool, updrights utils.RightBits, delfunc func(r *http.Request, data interface{}) bool, delrights utils.RightBits, url string) utils.Routes
CrudRoutesSpecificURL Generate default CRUD route for object with specific url
func DefaultQueryAll ¶
DefaultQueryAll default request for GetAll
func DefaultRightAccess ¶
DefaultRightAccess return true right handler
func DefaultRightEdit ¶
DefaultRightEdit return true right handler
func DeleteAssociation ¶
func DeleteAssociation(tx *gorm.DB, parent Validation, dataType Validation, associationName string, key string, fieldName string)
DeleteAssociation to remove association and data
func GenericCreate ¶
func GenericCreate(w http.ResponseWriter, r *http.Request, data Validation, f ...func(r *http.Request, data interface{}) bool)
GenericCreate create a new object
func GenericDelete ¶
func GenericDelete(w http.ResponseWriter, r *http.Request, data Validation, f func(r *http.Request, data interface{}) bool)
GenericDelete default deleter for controller
func GenericGet ¶
func GenericGet(w http.ResponseWriter, r *http.Request, data Validation, f func(r *http.Request, data interface{}) bool)
GenericGet default controller for get
func GenericGetQueryAll ¶
func GenericGetQueryAll(w http.ResponseWriter, r *http.Request, data Validation, freq func(r *http.Request, req *gorm.DB) *gorm.DB)
GenericGetQueryAll return all elements with filters
func GenericUpdate ¶
func GenericUpdate(w http.ResponseWriter, r *http.Request, data Validation, f func(r *http.Request, data interface{}, data2 interface{}) bool)
GenericUpdate default updater for controller
func GetAllFromDb ¶
GetAllFromDb return paginated database : offset, page size, order column
func GetFromID ¶
func GetFromID(r *http.Request, data Validation, preloads ...string) error
GetFromID Return object from Id
Types ¶
type Authed ¶
type Authed interface {
SetUserEmitter(userID uint)
}
Authed implement an element to set the id
type HistoryAble ¶
type HistoryAble interface { GetHistoryFields() map[string]string SetHistory([]map[string]interface{}) }
HistoryAble to store history on implementing objects
type Validation ¶
type Validation interface { TableName() string Validate() (map[string]interface{}, bool) OrderColumns() []string FilterColumns() map[string]string FindFromRequest(r *http.Request) error QueryAllFromRequest(r *http.Request, q *gorm.DB) *gorm.DB }
Validation interface to validate stuff