Documentation ¶
Index ¶
- func ChunkSlice[T any](slice []T, chunkSize int) [][]T
- func Map[T, U any](ts []T, f func(T) U) []U
- func MapDto[M GormModel[E], E any, T any](modelArray []M, dtoType T) []T
- type GormModel
- type GormRepository
- func (r *GormRepository[M, E]) Count(ctx context.Context, specifications ...Specification) (i int64, err error)
- func (r *GormRepository[M, E]) Delete(ctx context.Context, entity *E) error
- func (r *GormRepository[M, E]) DeleteById(ctx context.Context, id any) error
- func (r *GormRepository[M, E]) Find(ctx context.Context, specifications ...Specification) ([]E, error)
- func (r *GormRepository[M, E]) FindAll(ctx context.Context) ([]E, error)
- func (r *GormRepository[M, E]) FindByEntity(ctx context.Context, e any) ([]E, error)
- func (r *GormRepository[M, E]) FindByEntityWithOptions(ctx context.Context, e any, eagerLoad bool) ([]E, error)
- func (r *GormRepository[M, E]) FindByID(ctx context.Context, id any) (E, error)
- func (r *GormRepository[M, E]) FindByIDWithOptions(ctx context.Context, id any, eagerLoad bool) (E, error)
- func (r *GormRepository[M, E]) FindByModel(ctx context.Context, entity *M) (M, error)
- func (r *GormRepository[M, E]) FindByModelMulti(ctx context.Context, entity *M) ([]M, error)
- func (r *GormRepository[M, E]) FindPaged(ctx context.Context, specifications ...Specification) ([]E, error)
- func (r *GormRepository[M, E]) FindPagedWithLimit(ctx context.Context, pageCfg PageConfig, specifications ...Specification) (PageResult[M, E], error)
- func (r *GormRepository[M, E]) FindWithLimit(ctx context.Context, limit int, offset int, specifications ...Specification) ([]E, error)
- func (r *GormRepository[M, E]) FromModelToDto(models []M) []E
- func (r *GormRepository[M, E]) Insert(ctx context.Context, entity *E) error
- func (r *GormRepository[M, E]) InsertDirect(ctx context.Context, entity *M) error
- func (r *GormRepository[M, E]) InsertFromInterface(ctx context.Context, data interface{}) error
- func (r *GormRepository[M, E]) Update(ctx context.Context, entity *E) error
- func (r *GormRepository[M, E]) UpdateDirect(ctx context.Context, entity *M) error
- func (r *GormRepository[M, E]) UpdateDirectMulti(ctx context.Context, entity []M) error
- type PageConfig
- type PageResult
- type Specification
- func And(specifications ...Specification) Specification
- func Equal[T any](field string, value T) Specification
- func GreaterOrEqual[T comparable](field string, value T) Specification
- func GreaterThan[T comparable](field string, value T) Specification
- func In[T any](field string, value []T) Specification
- func IsNull(field string) Specification
- func LessOrEqual[T comparable](field string, value T) Specification
- func LessThan[T comparable](field string, value T) Specification
- func Like[T any](field string, value T) Specification
- func Not(specification Specification) Specification
- func Or(specifications ...Specification) Specification
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChunkSlice ¶
Types ¶
type GormRepository ¶
func NewRepository ¶
func NewRepository[M GormModel[E], E any](db *gorm.DB) *GormRepository[M, E]
func (*GormRepository[M, E]) Count ¶
func (r *GormRepository[M, E]) Count(ctx context.Context, specifications ...Specification) (i int64, err error)
func (*GormRepository[M, E]) Delete ¶
func (r *GormRepository[M, E]) Delete(ctx context.Context, entity *E) error
func (*GormRepository[M, E]) DeleteById ¶
func (r *GormRepository[M, E]) DeleteById(ctx context.Context, id any) error
func (*GormRepository[M, E]) Find ¶
func (r *GormRepository[M, E]) Find(ctx context.Context, specifications ...Specification) ([]E, error)
func (*GormRepository[M, E]) FindAll ¶
func (r *GormRepository[M, E]) FindAll(ctx context.Context) ([]E, error)
func (*GormRepository[M, E]) FindByEntity ¶
func (r *GormRepository[M, E]) FindByEntity(ctx context.Context, e any) ([]E, error)
func (*GormRepository[M, E]) FindByEntityWithOptions ¶
func (*GormRepository[M, E]) FindByID ¶
func (r *GormRepository[M, E]) FindByID(ctx context.Context, id any) (E, error)
func (*GormRepository[M, E]) FindByIDWithOptions ¶
func (*GormRepository[M, E]) FindByModel ¶
func (r *GormRepository[M, E]) FindByModel(ctx context.Context, entity *M) (M, error)
func (*GormRepository[M, E]) FindByModelMulti ¶
func (r *GormRepository[M, E]) FindByModelMulti(ctx context.Context, entity *M) ([]M, error)
func (*GormRepository[M, E]) FindPaged ¶ added in v0.1.2
func (r *GormRepository[M, E]) FindPaged(ctx context.Context, specifications ...Specification) ([]E, error)
func (*GormRepository[M, E]) FindPagedWithLimit ¶ added in v0.1.2
func (r *GormRepository[M, E]) FindPagedWithLimit(ctx context.Context, pageCfg PageConfig, specifications ...Specification) (PageResult[M, E], error)
func (*GormRepository[M, E]) FindWithLimit ¶
func (r *GormRepository[M, E]) FindWithLimit(ctx context.Context, limit int, offset int, specifications ...Specification) ([]E, error)
func (*GormRepository[M, E]) FromModelToDto ¶
func (r *GormRepository[M, E]) FromModelToDto(models []M) []E
func (*GormRepository[M, E]) Insert ¶
func (r *GormRepository[M, E]) Insert(ctx context.Context, entity *E) error
func (*GormRepository[M, E]) InsertDirect ¶
func (r *GormRepository[M, E]) InsertDirect(ctx context.Context, entity *M) error
func (*GormRepository[M, E]) InsertFromInterface ¶
func (r *GormRepository[M, E]) InsertFromInterface(ctx context.Context, data interface{}) error
func (*GormRepository[M, E]) Update ¶
func (r *GormRepository[M, E]) Update(ctx context.Context, entity *E) error
func (*GormRepository[M, E]) UpdateDirect ¶
func (r *GormRepository[M, E]) UpdateDirect(ctx context.Context, entity *M) error
func (*GormRepository[M, E]) UpdateDirectMulti ¶ added in v0.1.2
func (r *GormRepository[M, E]) UpdateDirectMulti(ctx context.Context, entity []M) error
type PageConfig ¶ added in v0.1.2
type PageConfig struct { Page int `json:"page"` Size int64 `json:"size"` // By default the count is generated when asking for the first page so that the user // receives the total amount, but with this we can optimize out this count IgnoreCount bool `json:"IngoreCount"` // if you want the count to always be returned. ForceCount bool `json:"ForceCount"` }
type PageResult ¶ added in v0.1.2
type Specification ¶
func And ¶
func And(specifications ...Specification) Specification
func Equal ¶
func Equal[T any](field string, value T) Specification
func GreaterOrEqual ¶
func GreaterOrEqual[T comparable](field string, value T) Specification
func GreaterThan ¶
func GreaterThan[T comparable](field string, value T) Specification
func In ¶
func In[T any](field string, value []T) Specification
func IsNull ¶
func IsNull(field string) Specification
func LessOrEqual ¶
func LessOrEqual[T comparable](field string, value T) Specification
func LessThan ¶
func LessThan[T comparable](field string, value T) Specification
func Like ¶
func Like[T any](field string, value T) Specification
func Not ¶
func Not(specification Specification) Specification
func Or ¶
func Or(specifications ...Specification) Specification
Click to show internal directories.
Click to hide internal directories.