repository

package
v0.0.0-...-053c64c Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbstractRepository

type AbstractRepository[E any] interface {
	CrudRepository[E]
	Finder[E]
	Counter[E]
}

type BaseRepository

type BaseRepository[E any] struct {
}

func (BaseRepository[E]) GetEntityType

func (repo BaseRepository[E]) GetEntityType() reflect.Type

type ComplexRepository

type ComplexRepository[E any] interface {
	Find(ctx context.Context, specifications ...Specification) ([]E, error)
	FindWithLimit(ctx context.Context, limit int, offset int, specifications ...Specification) ([]E, error)
	Count(ctx context.Context, specifications ...Specification) (i int64, err error)
}

type Counter

type Counter[E any] interface {
	Repository[E]
	Count(ctx context.Context, specifications ...Specification) (i int64, err error)
}

type CrudRepository

type CrudRepository[E any] interface {
	Repository[E]
	Inserter[E]
	Deleter[E]
	Updater[E]
	Lister[E]
	Getter[E]
}

type Deleter

type Deleter[E any] interface {
	Repository[E]
	Delete(ctx context.Context, entity *E) error
	DeleteById(ctx context.Context, id any) error
}

type Finder

type Finder[E any] interface {
	Repository[E]
	Find(ctx context.Context, specifications ...Specification) ([]E, error)
}

type GenericRepository

type GenericRepository[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
	Get(ctx context.Context, id any) (E, error)
	List(ctx context.Context) ([]E, error)
}

type Getter

type Getter[E any] interface {
	Repository[E]
	Get(ctx context.Context, id any) (E, error)
}

type GormDbDriver

type GormDbDriver string
const (
	InMemory GormDbDriver = "file::memory:?cache=shared"
)

type GormRepository

type GormRepository[E any] struct {
	BaseRepository[E]
	// contains filtered or unexported fields
}

func NewGormRepository

func NewGormRepository[E any](driver GormDbDriver, migrate MigrationInvoker, config *gorm.Config) *GormRepository[E]

func (GormRepository[E]) Count

func (repo GormRepository[E]) Count(ctx context.Context, specifications ...Specification) (i int64, err error)

func (GormRepository[E]) Delete

func (repo GormRepository[E]) Delete(ctx context.Context, entity *E) error

func (GormRepository[E]) DeleteById

func (repo GormRepository[E]) DeleteById(ctx context.Context, id any) error

func (GormRepository[E]) Find

func (repo GormRepository[E]) Find(ctx context.Context, specifications ...Specification) ([]E, error)

func (GormRepository[E]) Get

func (repo GormRepository[E]) Get(ctx context.Context, id any) (E, error)

func (GormRepository[E]) Insert

func (repo GormRepository[E]) Insert(ctx context.Context, entity *E) error

func (GormRepository[E]) List

func (repo GormRepository[E]) List(ctx context.Context) ([]E, error)

func (GormRepository[E]) Update

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

type Inserter

type Inserter[E any] interface {
	Repository[E]
	Insert(ctx context.Context, entity *E) error
}

type Lister

type Lister[E any] interface {
	Repository[E]
	List(ctx context.Context) ([]E, error)
}

type MigrationInvoker

type MigrationInvoker func(db *gorm.DB)

type Repository

type Repository[E any] interface {
	GetEntityType() reflect.Type
}

type Specification

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

type Updater

type Updater[E any] interface {
	Repository[E]
	Update(ctx context.Context, entity *E) error
}

Jump to

Keyboard shortcuts

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