repository

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRecordNotFound = gorm.ErrRecordNotFound

Functions

This section is empty.

Types

type IDType

type IDType interface {
	comparable
}

type PageableRequest

type PageableRequest struct {
	Page int
	Size int
	Sort []string
}

type PageableResponse

type PageableResponse[T any] struct {
	Page       int
	Size       int
	Data       []T
	TotalCount int
	TotalPage  int
}

type Repository

type Repository[Id IDType, T any] interface {
	FindByID(ctx context.Context, id Id) (*T, error)
	FindOne(ctx context.Context, q query.Query) (*T, error)
	FindAll(ctx context.Context, q query.Query) ([]*T, error)
	Update(ctx context.Context, q query.Query, update any) error
	Save(ctx context.Context, t *T) (*T, error)
	SaveAll(ctx context.Context, ts []*T) error
	DeleteByID(ctx context.Context, id Id) error
	Delete(ctx context.Context, q query.Query) error
	ListPageable(ctx context.Context, q query.Query, req PageableRequest) (*PageableResponse[*T], error)
	ParseQuery(ctx context.Context, q query.Query) *gorm.DB
	Context(ctx context.Context) *gorm.DB
}

func New

func New[Id IDType, T any](gp orm.GormProvider) Repository[Id, T]

Jump to

Keyboard shortcuts

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