database

package
v0.0.0-...-c78e9a6 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: LGPL-2.1 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindOne

func FindOne[TDb any, TDomain any](
	ctx context.Context,
	queryBuilder QueryOneBuilder[TDb],
	isNotFoundFn func(err error) bool,
	convertFn EntToDomainFn[TDb, TDomain],
) (*TDomain, error)

func InitSubModule

func InitSubModule(params InitParams) error

func List

func List[TDb any, TDomain any, TQuery interface {
	All(context.Context) ([]*TDb, error)
}](
	ctx context.Context,
	query TQuery,
	convertFn func([]*TDb) []TDomain,
) ([]TDomain, error)

func Mutate

func Mutate[TDb any, TDomain any](
	ctx context.Context,
	mutationBuilder MutationBuilder[TDb],
	isNotFoundFn func(err error) bool,
	convertFn EntToDomainFn[TDb, TDomain],
) (*TDomain, error)

func MutateBulk

func MutateBulk[TDb any, TDomain any](
	ctx context.Context,
	mutationBuilder MutationBulkBuilder[TDb],
	isNotFoundFn func(err error) bool,
	convertFn EntToDomainArrFn[TDb, TDomain],
) ([]TDomain, error)

func ParseSearchGraph

func ParseSearchGraph[TDb any, TDomain any](criteria *orm.SearchGraph, entityName string) (*orm.Predicate, []orm.OrderOption, ft.ValidationErrors)

func ParseSearchGraphStr

func ParseSearchGraphStr[TDb any, TDomain any](criteria *string, entityName string) (*orm.Predicate, []orm.OrderOption, ft.ValidationErrors)

Types

type DbLock

type DbLock struct {
	Tranx DbTransaction
}

func FindOneForUpdate

func FindOneForUpdate[TDb any, TDomain any, TQuery interface {
	Only(context.Context) (*TDb, error)
	ForUpdate(opts ...sql.LockOption) TQuery
}](
	ctx context.Context,
	queryBuilder TQuery,
	isNotFoundFn func(err error) bool,
	convertFn EntToDomainFn[TDb, TDomain],
	tranx DbTransaction,
) (*TDomain, *DbLock, error)

type DbTransaction

type DbTransaction interface {
	Commit() error
	Rollback() error
}

type EntClientOptions

type EntClientOptions struct {
	Driver       *entsql.Driver
	DebugEnabled bool
}

type EntRepositoryBase

type EntRepositoryBase struct {
}

type EntToDomainArrFn

type EntToDomainArrFn[TDb any, TDomain any] func([]*TDb) []TDomain

type EntToDomainFn

type EntToDomainFn[TDb any, TDomain any] func(*TDb) *TDomain

type InitParams

type InitParams struct {
	dig.In

	Config config.ConfigService
	Logger logging.LoggerService
}

type MutationBuilder

type MutationBuilder[TDb any] interface {
	Save(context.Context) (*TDb, error)
}

type MutationBulkBuilder

type MutationBulkBuilder[TDb any] interface {
	Save(context.Context) ([]*TDb, error)
}

type PagedResult

type PagedResult[T any] struct {
	Items []T `json:"items"`
	Total int `json:"total"`
	Page  int `json:"page"`
	Size  int `json:"size"`
}
func Search[TDb any, TDomain any, TQuery interface {
	Where(...orm.Predicate) TQuery
	Clone() TQuery
	Count(context.Context) (int, error)
	Offset(int) TQuery
	Limit(int) TQuery
	Order(...orm.OrderOption) TQuery
	All(context.Context) ([]*TDb, error)
}](
	ctx context.Context,
	predicate *orm.Predicate,
	order []orm.OrderOption,
	opts PagingOptions,
	query TQuery,
	convertFn func([]*TDb) []TDomain,
) (*PagedResult[TDomain], error)

type PagingOptions

type PagingOptions struct {
	Page int `json:"page" query:"page"`
	Size int `json:"size" query:"size"`
}

type QueryOneBuilder

type QueryOneBuilder[TDb any] interface {
	Only(context.Context) (*TDb, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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