Documentation
¶
Index ¶
- func ApplyPaging[T any](items []*T, paging query.Paging) []*T
- func FilterExpressionAsPredicate[T any](fe query.FilterExpression, item *T) bool
- func InExpressionAsPredicate[T any](ie query.InExpression, item *T) bool
- func JunctionExpressionPredicate[T any](je query.JunctionExpression, item *T) bool
- func LoadAll[T any](ctx context.Context, c GenericInterface[T], fe query.FilterExpression, ...) ([]*T, error)
- func LoadAllInBatch[T any](ctx context.Context, c GenericInterface[T], fe query.FilterExpression, ...) ([]*T, error)
- func LoadAllInBatchWithCap[T any](ctx context.Context, c GenericInterface[T], fe query.FilterExpression, ...) ([]*T, error)
- func NewApi(endpoint string, opts ...api.ClientOption) (api.ClientWithResponsesInterface, error)
- func NotExpressionAsPredicate[T any](ne query.NotExpression, item *T) bool
- func SimpleExpressionPredicate[T any](se query.SimpleExpression, item *T) bool
- type DecoderFn
- type EncoderFn
- type GenericInterface
- type GenericOpt
- type Opt
- func IdProperty[T any](prop string) Opt[T]
- func ReadOnlyProperties[T any](props []string) Opt[T]
- func WithClientOptions[T any](copts ...api.ClientOption) Opt[T]
- func WithLogger[T any](l *slog.Logger) Opt[T]
- func WithPayloadDecoder[T any](decFn DecoderFn[T]) Opt[T]
- func WithPayloadEncoder[T any](encFn EncoderFn[T]) Opt[T]
- type RawInterface
- type RawOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyPaging ¶ added in v1.0.7
func FilterExpressionAsPredicate ¶ added in v1.0.7
func FilterExpressionAsPredicate[T any](fe query.FilterExpression, item *T) bool
func InExpressionAsPredicate ¶ added in v1.0.7
func InExpressionAsPredicate[T any](ie query.InExpression, item *T) bool
func JunctionExpressionPredicate ¶ added in v1.0.7
func JunctionExpressionPredicate[T any](je query.JunctionExpression, item *T) bool
func LoadAll ¶ added in v1.0.7
func LoadAll[T any](ctx context.Context, c GenericInterface[T], fe query.FilterExpression, orders ...query.Order) ([]*T, error)
func LoadAllInBatch ¶ added in v1.0.7
func LoadAllInBatch[T any](ctx context.Context, c GenericInterface[T], fe query.FilterExpression, batchSize int, orders ...query.Order) ([]*T, error)
func LoadAllInBatchWithCap ¶ added in v1.0.8
func NewApi ¶ added in v1.0.8
func NewApi(endpoint string, opts ...api.ClientOption) (api.ClientWithResponsesInterface, error)
func NotExpressionAsPredicate ¶ added in v1.0.7
func NotExpressionAsPredicate[T any](ne query.NotExpression, item *T) bool
func SimpleExpressionPredicate ¶ added in v1.0.7
func SimpleExpressionPredicate[T any](se query.SimpleExpression, item *T) bool
Types ¶
type GenericInterface ¶
type GenericInterface[T any] interface { // Api get access to generated OpenAPI interface Api() api.ClientWithResponsesInterface // Raw gets access to untyped API Raw() RawInterface Create(context.Context, *T) (*T, error) Get(context.Context, string) (*T, error) List(context.Context, query.Interface) ([]*T, int, error) Update(context.Context, string, *T) (*T, error) // Delete removes single entity instance by its ID Delete(context.Context, string) error BulkUpdate(context.Context, []*T, api.BulkUpdateMode) error Query(context.Context, string, query.Interface, []string) ([]*T, int, error) }
func New ¶
func New[T any](endpoint, backend, entity string, opts ...Opt[T]) (GenericInterface[T], error)
func NewInMemory ¶ added in v1.0.7
func NewInMemory[T any](isKeyFn func(string, *T) bool, initData []*T) GenericInterface[T]
type GenericOpt ¶ added in v1.0.8
type GenericOpt[T any] func(*generic[T])
type Opt ¶
type Opt[T any] func(*generic[T])
func IdProperty ¶ added in v1.0.7
IdProperty can override default ID property ("id")
func ReadOnlyProperties ¶ added in v1.0.7
ReadOnlyProperties sets properties that will not be sent to REST API during create/update operations. Such properties might be generated by backend itself, ie auto_increment columns or timestamps.
func WithClientOptions ¶
func WithClientOptions[T any](copts ...api.ClientOption) Opt[T]
func WithPayloadDecoder ¶
func WithPayloadEncoder ¶
type RawInterface ¶ added in v1.0.7
type RawInterface interface {
// Create creates new entity instance
Create(context.Context, api.UntypedDto) (*api.UntypedDto, error)
// Get gets single entity instance by its ID
Get(context.Context, string) (*api.UntypedDto, error)
// List lists entity instances based on provided query
List(context.Context, query.Interface) (*api.PagedResult, error)
// Update updates single entity identified by its key with values provided as map.
// This method exists to address limitation of generic API to perform updates by i.e. skipping empty strings.
Update(context.Context, string, api.UntypedDto) (*api.UntypedDto, error)
// BulkUpdate perform multiple mutation operations in one transaction
BulkUpdate(context.Context, []api.UntypedDto, api.BulkUpdateMode) error
// Query executes named query already defined in server-side configuration and returns result.
Query(context.Context, string, query.Interface, []string) (*api.PagedResult, error)
}
Click to show internal directories.
Click to hide internal directories.