Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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.
Click to show internal directories.
Click to hide internal directories.