lister

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregator added in v0.9.0

type Aggregator struct {
	// contains filtered or unexported fields
}

Aggregator contains the query builders for filters and aggregate functions for summary

func OfRecordList added in v0.9.0

func OfRecordList(env *cel.Env, resultParent, resultName string, request *pb.RecordListSummaryRequest) (*Aggregator, error)

OfRecordList returns a new Aggregator for Record List Summary Request

func (*Aggregator) Aggregate added in v0.9.0

func (a *Aggregator) Aggregate(ctx context.Context, db *gorm.DB) (*pb.RecordListSummary, error)

Aggregate function runs the aggregation tasks and returns Summary

type Converter

type Converter[M any, W wireObject] func(M) W

Converter is a generic function which converts a database model to its wire form.

type Lister

type Lister[M any, W wireObject] struct {
	// contains filtered or unexported fields
}

Lister is a generic utility to list, filter, sort and paginate Results and Records in a uniform and consistent manner.

func OfRecords

func OfRecords(env *cel.Env, resultParent, resultName string, request *resultspb.ListRecordsRequest) (*Lister[*db.Record, *resultspb.Record], error)

OfRecords creates a Lister for Record objects.

func OfResults

func OfResults(env *cel.Env, request *resultspb.ListResultsRequest) (*Lister[*db.Result, *resultspb.Result], error)

OfResults creates a Lister for Result objects.

func (*Lister[M, W]) List

func (l *Lister[M, W]) List(ctx context.Context, db *gorm.DB) ([]W, string, error)

List lists resources applying filters, sorting elements and handling pagination. It returns resources in their wire form and a token to be used later for retrieving more pages if applicable.

type PageTokenGenerator

type PageTokenGenerator func(wireObject) (string, error)

PageTokenGenerator takes a wire object and returns a page token for retrieving more resources from thee API.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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