Documentation ¶
Index ¶
- Constants
- Variables
- func LazyLoadNow[T any](name string, lazyLoader LazyLoadable) (T, error)
- func NewDummyTransactionManager() *dummyTransactionManager
- type Association
- type AssociationType
- type DTO
- type DtoWrapFindByRepository
- type DtoWrapRepository
- func (d *DtoWrapRepository[D, M, ID]) Create(ctx context.Context, entity M) (M, error)
- func (d *DtoWrapRepository[D, M, ID]) Delete(ctx context.Context, entity M) error
- func (d *DtoWrapRepository[D, M, ID]) FindOne(ctx context.Context, id ID) (M, error)
- func (d *DtoWrapRepository[D, M, ID]) Update(ctx context.Context, entity M) (M, error)
- type FetchMode
- type FindByRepository
- type GormFindByRepository
- type GormRepository
- func (u *GormRepository[T, ID]) Create(ctx context.Context, entity T) (T, error)
- func (u *GormRepository[T, ID]) Delete(ctx context.Context, entity T) error
- func (u *GormRepository[T, ID]) FindBy(ctx context.Context, name string, byEntity any) ([]T, error)
- func (u *GormRepository[T, ID]) FindOne(ctx context.Context, id ID) (T, error)
- func (u *GormRepository[T, ID]) GetLazyLoadFuncOfBelongTo(ctx context.Context, ptrToEntity any, id any) func() (any, error)
- func (u *GormRepository[T, ID]) GetLazyLoadFuncOfHasMany(ctx context.Context, ptrToEntity any, foreignKey string, foreignKeyValue any) func() (any, error)
- func (u *GormRepository[T, ID]) GetLazyLoadFuncOfHasOne(ctx context.Context, ptrToEntity any, foreignKey string, foreignKeyValue any) func() (any, error)
- func (u *GormRepository[T, ID]) GetLazyLoadFuncOfManyMany(ctx context.Context, ptrToParent any, ptrToChildren any, ...) func() (any, error)
- func (u *GormRepository[T, ID]) Update(ctx context.Context, entity T) (T, error)
- type GormTransactionManager
- type InMemoryRepository
- func (u *InMemoryRepository[T, ID]) Create(ctx context.Context, entity T) (T, error)
- func (u *InMemoryRepository[T, ID]) Delete(ctx context.Context, entity T) error
- func (u *InMemoryRepository[T, ID]) FindBy(ctx context.Context, name string, byEntity any) ([]T, error)
- func (u *InMemoryRepository[T, ID]) FindOne(ctx context.Context, id ID) (T, error)
- func (u *InMemoryRepository[T, ID]) Update(ctx context.Context, entity T) (T, error)
- type Lazy
- type LazyLoad
- type LazyLoadable
- type LazyLoader
- func (l *LazyLoader) DeleteLoadFunc(entity string)
- func (l *LazyLoader) Entities() []string
- func (l *LazyLoader) HasLoadFunc(entity string) bool
- func (l *LazyLoader) Load(name string, emptyEntity any) (any, error)
- func (l *LazyLoader) NewInstance()
- func (l *LazyLoader) SetLoadFunc(entity string, fn func() (any, error))
- type Repository
- type TransactionManager
Constants ¶
View Source
const ( FetchEagerMode = "eager" FetchLazyMode = "lazy" )
Variables ¶
View Source
var NotFoundError = errors.New("not found")
Functions ¶
func LazyLoadNow ¶
func LazyLoadNow[T any](name string, lazyLoader LazyLoadable) (T, error)
func NewDummyTransactionManager ¶
func NewDummyTransactionManager() *dummyTransactionManager
Types ¶
type Association ¶
type AssociationType ¶
type AssociationType int
const ( BelongTo AssociationType = iota + 1 HasOne HasMany ManyToMany )
type DtoWrapFindByRepository ¶
type DtoWrapFindByRepository[D DTO[M], M any, E DTO[S], S any] struct { // contains filtered or unexported fields }
func NewDtoWrapFindByRepository ¶
func NewDtoWrapFindByRepository[D DTO[M], M any, E DTO[S], S any](dtoRepository FindByRepository[D, E]) *DtoWrapFindByRepository[D, M, E, S]
type DtoWrapRepository ¶
type DtoWrapRepository[D DTO[M], M any, ID comparable] struct { // contains filtered or unexported fields }
func NewDtoWrapRepository ¶
func NewDtoWrapRepository[D DTO[M], M any, ID comparable](dtoRepository Repository[D, ID]) *DtoWrapRepository[D, M, ID]
func (*DtoWrapRepository[D, M, ID]) Create ¶
func (d *DtoWrapRepository[D, M, ID]) Create(ctx context.Context, entity M) (M, error)
func (*DtoWrapRepository[D, M, ID]) Delete ¶
func (d *DtoWrapRepository[D, M, ID]) Delete(ctx context.Context, entity M) error
type FindByRepository ¶
type GormFindByRepository ¶
type GormFindByRepository[T any, S any, ID comparable] struct { *GormRepository[T, ID] }
func NewGormFindByRepository ¶
func NewGormFindByRepository[T any, S any, ID comparable](gormRepository *GormRepository[T, ID]) *GormFindByRepository[T, S, ID]
type GormRepository ¶
type GormRepository[T any, ID comparable] struct { // contains filtered or unexported fields }
func NewGormRepository ¶
func NewGormRepository[T any, ID comparable](transactionManager TransactionManager) *GormRepository[T, ID]
func (*GormRepository[T, ID]) Create ¶
func (u *GormRepository[T, ID]) Create(ctx context.Context, entity T) (T, error)
func (*GormRepository[T, ID]) Delete ¶
func (u *GormRepository[T, ID]) Delete(ctx context.Context, entity T) error
func (*GormRepository[T, ID]) FindOne ¶
func (u *GormRepository[T, ID]) FindOne(ctx context.Context, id ID) (T, error)
func (*GormRepository[T, ID]) GetLazyLoadFuncOfBelongTo ¶
func (u *GormRepository[T, ID]) GetLazyLoadFuncOfBelongTo(ctx context.Context, ptrToEntity any, id any) func() (any, error)
GetLazyLoadFuncOfBelongTo returns entity returning function
func (*GormRepository[T, ID]) GetLazyLoadFuncOfHasMany ¶
func (u *GormRepository[T, ID]) GetLazyLoadFuncOfHasMany(ctx context.Context, ptrToEntity any, foreignKey string, foreignKeyValue any) func() (any, error)
GetLazyLoadFuncOfHasMany returns slice of entity returning function
func (*GormRepository[T, ID]) GetLazyLoadFuncOfHasOne ¶
func (u *GormRepository[T, ID]) GetLazyLoadFuncOfHasOne(ctx context.Context, ptrToEntity any, foreignKey string, foreignKeyValue any) func() (any, error)
GetLazyLoadFuncOfHasOne returns entity returning function
func (*GormRepository[T, ID]) GetLazyLoadFuncOfManyMany ¶
func (u *GormRepository[T, ID]) GetLazyLoadFuncOfManyMany(ctx context.Context, ptrToParent any, ptrToChildren any, associationName string, foreignKey string, foreignKeyValue any) func() (any, error)
GetLazyLoadFuncOfManyMany returns slice of entity returning function
type GormTransactionManager ¶
type GormTransactionManager struct {
// contains filtered or unexported fields
}
func NewGormTransactionManager ¶
func NewGormTransactionManager(db *gorm.DB) *GormTransactionManager
type InMemoryRepository ¶
type InMemoryRepository[T any, ID comparable] struct { // contains filtered or unexported fields }
func NewInMemoryRepository ¶
func NewInMemoryRepository[T any, ID comparable](transactionManager TransactionManager) *InMemoryRepository[T, ID]
func (*InMemoryRepository[T, ID]) Create ¶
func (u *InMemoryRepository[T, ID]) Create(ctx context.Context, entity T) (T, error)
func (*InMemoryRepository[T, ID]) Delete ¶
func (u *InMemoryRepository[T, ID]) Delete(ctx context.Context, entity T) error
type LazyLoad ¶
type LazyLoad[T any] struct { // contains filtered or unexported fields }
func LazyLoadValue ¶
type LazyLoadable ¶
type LazyLoader ¶
type LazyLoader struct {
// contains filtered or unexported fields
}
func (*LazyLoader) DeleteLoadFunc ¶
func (l *LazyLoader) DeleteLoadFunc(entity string)
func (*LazyLoader) Entities ¶
func (l *LazyLoader) Entities() []string
func (*LazyLoader) HasLoadFunc ¶
func (l *LazyLoader) HasLoadFunc(entity string) bool
func (*LazyLoader) NewInstance ¶
func (l *LazyLoader) NewInstance()
func (*LazyLoader) SetLoadFunc ¶
func (l *LazyLoader) SetLoadFunc(entity string, fn func() (any, error))
type Repository ¶
Click to show internal directories.
Click to hide internal directories.