loader

package
v0.0.0-...-1dd8909 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrObjectNotFound = fmt.Errorf("object could not be found: %w", pgx.ErrNoRows)

Functions

func LoadModels

func LoadModels[Key comparable, DBModel comparable, GraphModel comparable](
	ctx context.Context,
	keys []Key,
	loaderFn func(context.Context, []Key) ([]DBModel, error),
	toGraphFn func(DBModel) GraphModel,
	makeKey func(GraphModel) Key,
) ([]GraphModel, []error)

func LoadModelsWithError

func LoadModelsWithError[Key comparable, DBModel comparable, GraphModel comparable](
	ctx context.Context,
	keys []Key,
	loaderFn func(context.Context, []Key) ([]DBModel, error),
	toGraphFn func(DBModel) (GraphModel, error),
	makeKey func(GraphModel) Key,
) ([]GraphModel, []error)

func Middleware

func Middleware(fn func(context.Context) context.Context) func(http.Handler) http.Handler

Middleware injects data loaders into the context

Types

This section is empty.

Jump to

Keyboard shortcuts

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