repository

package
v0.0.0-...-0c778b9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChunkSlice

func ChunkSlice[T any](slice []T, chunkSize int) [][]T

Types

type GormRepository

type GormRepository[M entity.Model[E], E entity.IEntity] struct {
	// contains filtered or unexported fields
}

func NewRepository

func NewRepository[M entity.Model[E], E entity.IEntity](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 entity.ID) error

func (*GormRepository[M, E]) DisablePreloadAssociations

func (r *GormRepository[M, E]) DisablePreloadAssociations() *GormRepository[M, E]

func (*GormRepository[M, E]) EnablePreloadAssociations

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

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 entity.ID) (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]) GetDB

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]) NewEntity

func (r GormRepository[M, E]) NewEntity() E

func (*GormRepository[M, E]) SetPreloadAssociations

func (r *GormRepository[M, E]) SetPreloadAssociations(association bool) *GormRepository[M, E]

func (*GormRepository[M, E]) Update

func (r *GormRepository[M, E]) Update(ctx context.Context, entity *E) error

type Specification

type Specification interface {
	GetQuery() string
	GetValues() []any
}

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 Not

func Not(specification Specification) Specification

func Or

func Or(specifications ...Specification) Specification

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL