Documentation ¶
Index ¶
- func ChunkSlice[T any](slice []T, chunkSize int) [][]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]) DisablePreloadAssociations() *GormRepository[M, E]
- func (r *GormRepository[M, E]) EnablePreloadAssociations() *GormRepository[M, E]
- 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]) FindByID(ctx context.Context, id any) (E, error)
- func (r *GormRepository[M, E]) FindWithLimit(ctx context.Context, limit int, offset int, specifications ...Specification) ([]E, error)
- func (r GormRepository[M, E]) GetDB() *gorm.DB
- func (r *GormRepository[M, E]) Insert(ctx context.Context, entity *E) error
- func (r *GormRepository[M, E]) SetPreloadAssociations(association bool) *GormRepository[M, E]
- func (r *GormRepository[M, E]) Update(ctx context.Context, entity *E) error
- type IRepository
- 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 Not(specification Specification) Specification
- func Or(specifications ...Specification) Specification
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChunkSlice ¶ added in v0.0.4
Types ¶
type GormRepository ¶
func NewRepository ¶
func NewRepository[M GormModel[E], E any](db *gorm.DB) *GormRepository[M, E]
func (*GormRepository[M, E]) Count ¶ added in v0.0.2
func (r *GormRepository[M, E]) Count(ctx context.Context, specifications ...Specification) (i int64, err error)
func (*GormRepository[M, E]) Delete ¶ added in v0.0.4
func (r *GormRepository[M, E]) Delete(ctx context.Context, entity *E) error
func (*GormRepository[M, E]) DeleteByID ¶ added in v0.0.10
func (r *GormRepository[M, E]) DeleteByID(ctx context.Context, id any) error
func (*GormRepository[M, E]) DisablePreloadAssociations ¶ added in v0.0.6
func (r *GormRepository[M, E]) DisablePreloadAssociations() *GormRepository[M, E]
func (*GormRepository[M, E]) EnablePreloadAssociations ¶ added in v0.0.6
func (r *GormRepository[M, E]) EnablePreloadAssociations() *GormRepository[M, E]
func (*GormRepository[M, E]) Find ¶
func (r *GormRepository[M, E]) Find(ctx context.Context, specifications ...Specification) ([]E, error)
func (*GormRepository[M, E]) FindAll ¶ added in v0.0.2
func (r *GormRepository[M, E]) FindAll(ctx context.Context) ([]E, error)
func (*GormRepository[M, E]) FindByID ¶
func (r *GormRepository[M, E]) FindByID(ctx context.Context, id any) (E, error)
func (*GormRepository[M, E]) FindWithLimit ¶ added in v0.0.2
func (r *GormRepository[M, E]) FindWithLimit(ctx context.Context, limit int, offset int, specifications ...Specification) ([]E, error)
func (GormRepository[M, E]) GetDB ¶ added in v0.0.8
func (r GormRepository[M, E]) GetDB() *gorm.DB
func (*GormRepository[M, E]) Insert ¶
func (r *GormRepository[M, E]) Insert(ctx context.Context, entity *E) error
func (*GormRepository[M, E]) SetPreloadAssociations ¶ added in v0.0.6
func (r *GormRepository[M, E]) SetPreloadAssociations(association bool) *GormRepository[M, E]
type IRepository ¶ added in v0.0.10
type IRepository[M GormModel[E], E any] interface { Insert(ctx context.Context, entity *E) error Delete(ctx context.Context, entity *E) error DeleteByID(ctx context.Context, id any) error Update(ctx context.Context, entity *E) error FindByID(ctx context.Context, id any) (E, error) Find(ctx context.Context, specifications ...Specification) ([]E, error) Count(ctx context.Context, specifications ...Specification) (int64, error) FindWithLimit(ctx context.Context, limit int, offset int, specifications ...Specification) ([]E, error) FindAll(ctx context.Context) ([]E, error) }
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 ¶ added in v0.0.8
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 Not ¶
func Not(specification Specification) Specification
func Or ¶
func Or(specifications ...Specification) Specification
Click to show internal directories.
Click to hide internal directories.