Documentation ¶
Index ¶
- func CreateTx(hooks ...CreateTxHooks) func(crud.CreateQueryFunc) crud.CreateQueryFunc
- func CtxInitQuery(ctx *gin.Context)
- func CtxQuery(ctx *gin.Context) *gorm.DB
- func CtxSetFactory(ctx *gin.Context, factory GormORMFactory)
- func CtxSetQuery(ctx *gin.Context, db *gorm.DB)
- func DestroyTx(hooks ...DestroyTxHooks) func(crud.DestroyQueryFunc) crud.DestroyQueryFunc
- func FromDBConverter[Model any]() func(map[string]any) (models.InternalValue, error)
- func GormQueries[Model any]() *crud.CRUD[Model]
- func New(ctx *gin.Context) *gorm.DB
- func SQLScannerOrPassthrough[Model any]() func(map[string]any, string, *gin.Context) (any, error)
- func UpdateTx(hooks ...UpdateTxHooks) func(crud.UpdateQueryFunc) crud.UpdateQueryFunc
- type CreateTxHook
- type CreateTxHooks
- type DestroyTxHook
- type DestroyTxHooks
- type GormFilterFunc
- type GormORMFactory
- type GormQueryDriver
- func (g GormQueryDriver[Model]) CRUD() *crud.CRUD[Model]
- func (g GormQueryDriver[Model]) Filter() common.QueryMod
- func (g GormQueryDriver[Model]) Middleware() []gin.HandlerFunc
- func (g GormQueryDriver[Model]) Order() common.QueryMod
- func (g GormQueryDriver[Model]) Pagination() common.Pagination
- func (g *GormQueryDriver[Model]) WithFilter(filterFunc GormFilterFunc) *GormQueryDriver[Model]
- func (g *GormQueryDriver[Model]) WithOrderBy(orderClause any) *GormQueryDriver[Model]
- func (g *GormQueryDriver[Model]) WithPagination(pagination Pagination) *GormQueryDriver[Model]
- type LimitOffsetPagination
- type NoPagination
- type Pagination
- type UpdateTxHook
- type UpdateTxHooks
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTx ¶
func CreateTx(hooks ...CreateTxHooks) func(crud.CreateQueryFunc) crud.CreateQueryFunc
func CtxInitQuery ¶
func CtxSetFactory ¶
func CtxSetFactory(ctx *gin.Context, factory GormORMFactory)
func DestroyTx ¶
func DestroyTx(hooks ...DestroyTxHooks) func(crud.DestroyQueryFunc) crud.DestroyQueryFunc
func FromDBConverter ¶
FromDBConverter internally uses *sql.Scanner to convert a map[string]any to an InternalValue as GORM does this only for structs
func GormQueries ¶
GormQueries returns default queries providing basic CRUD functionality
func SQLScannerOrPassthrough ¶
func UpdateTx ¶
func UpdateTx(hooks ...UpdateTxHooks) func(crud.UpdateQueryFunc) crud.UpdateQueryFunc
Types ¶
type CreateTxHook ¶
type CreateTxHook func(ctx *gin.Context, iv models.InternalValue, db *gorm.DB) (models.InternalValue, error)
type CreateTxHooks ¶
type CreateTxHooks struct {
// contains filtered or unexported fields
}
func AfterCreate ¶
func AfterCreate(hook CreateTxHook) CreateTxHooks
func BeforeCreate ¶
func BeforeCreate(hook CreateTxHook) CreateTxHooks
type DestroyTxHooks ¶
type DestroyTxHooks struct {
// contains filtered or unexported fields
}
func AfterDestroy ¶
func AfterDestroy(hook DestroyTxHook) DestroyTxHooks
func BeforeDestroy ¶
func BeforeDestroy(hook DestroyTxHook) DestroyTxHooks
type GormORMFactory ¶
func CtxGetFactory ¶
func CtxGetFactory(ctx *gin.Context) GormORMFactory
func Dynamic ¶
func Dynamic(dbFunc func(*gin.Context) *gorm.DB) GormORMFactory
Dynamic creates a GormORMFactory that provides a gorm.DB instance for each request, using the provided function. Make sure to create a new session for each query (if needed).
func Static ¶
func Static(db *gorm.DB) GormORMFactory
Static creates a GormORMFactory that always returns the same gorm.DB instance, creating new sessions for each query.
type GormQueryDriver ¶
type GormQueryDriver[Model any] struct { // contains filtered or unexported fields }
func Gorm ¶
func Gorm[Model any](factory GormORMFactory) *GormQueryDriver[Model]
func (GormQueryDriver[Model]) CRUD ¶
func (g GormQueryDriver[Model]) CRUD() *crud.CRUD[Model]
func (GormQueryDriver[Model]) Filter ¶
func (g GormQueryDriver[Model]) Filter() common.QueryMod
func (GormQueryDriver[Model]) Middleware ¶
func (g GormQueryDriver[Model]) Middleware() []gin.HandlerFunc
func (GormQueryDriver[Model]) Order ¶
func (g GormQueryDriver[Model]) Order() common.QueryMod
func (GormQueryDriver[Model]) Pagination ¶
func (g GormQueryDriver[Model]) Pagination() common.Pagination
func (*GormQueryDriver[Model]) WithFilter ¶
func (g *GormQueryDriver[Model]) WithFilter(filterFunc GormFilterFunc) *GormQueryDriver[Model]
func (*GormQueryDriver[Model]) WithOrderBy ¶
func (g *GormQueryDriver[Model]) WithOrderBy(orderClause any) *GormQueryDriver[Model]
func (*GormQueryDriver[Model]) WithPagination ¶
func (g *GormQueryDriver[Model]) WithPagination(pagination Pagination) *GormQueryDriver[Model]
type LimitOffsetPagination ¶
type LimitOffsetPagination struct { }
type NoPagination ¶
type NoPagination struct{}
type Pagination ¶
type UpdateTxHook ¶
type UpdateTxHook func(ctx *gin.Context, old models.InternalValue, new models.InternalValue, id any, db *gorm.DB) (models.InternalValue, error)
type UpdateTxHooks ¶
type UpdateTxHooks struct {
// contains filtered or unexported fields
}
func AfterUpdate ¶
func AfterUpdate(hook UpdateTxHook) UpdateTxHooks
func BeforeUpdate ¶
func BeforeUpdate(hook UpdateTxHook) UpdateTxHooks
Click to show internal directories.
Click to hide internal directories.