client

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyPaging added in v1.0.7

func ApplyPaging[T any](items []*T, paging query.Paging) []*T

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 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 DecoderFn

type DecoderFn[T any] func(dto api.UntypedDto) (*T, error)

type EncoderFn

type EncoderFn[T any] func(*T) (api.UntypedDto, error)

type GenericInterface

type GenericInterface[T any] interface {
	RawInterface
	List(context.Context, query.Interface) ([]*T, int, error)
	Create(context.Context, *T) (*T, error)
	Get(context.Context, string) (*T, error)
	Delete(context.Context, string) error
	Update(context.Context, string, *T) (*T, error)
	BulkUpdate(context.Context, []*T, api.BulkUpdateMode) 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 Opt

type Opt[T any] func(*generic[T])

func IdProperty added in v1.0.7

func IdProperty[T any](prop string) Opt[T]

IdProperty can override default ID property ("id")

func ReadOnlyProperties added in v1.0.7

func ReadOnlyProperties[T any](props []string) Opt[T]

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 SkipProperties

func SkipProperties[T any](props []string) Opt[T]

deprecated: use ReadOnlyProperties.

func WithClientOptions

func WithClientOptions[T any](copts ...api.ClientOption) Opt[T]

func WithLogger

func WithLogger[T any](l *slog.Logger) Opt[T]

func WithPayloadDecoder

func WithPayloadDecoder[T any](decFn DecoderFn[T]) Opt[T]

func WithPayloadEncoder

func WithPayloadEncoder[T any](encFn EncoderFn[T]) Opt[T]

type RawInterface added in v1.0.7

type RawInterface interface {
	Query(context.Context, string, query.Interface, []string) (*api.PagedResult, error)
}

Jump to

Keyboard shortcuts

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