framedata

package
v1.62.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StableSearch

func StableSearch[T any](
	ctx context.Context, svc *frame.Service,
	query *SearchQuery, searchFunc func(ctx context.Context, query *SearchQuery) ([]T, error),
) (workerpool.JobResultPipe[[]T], error)

Types

type BaseRepository added in v1.61.0

type BaseRepository[T any] interface {
	Svc() *frame.Service
	GetByID(ctx context.Context, id string) (T, error)
	GetLastestBy(ctx context.Context, properties map[string]any) (T, error)
	GetAllBy(ctx context.Context, properties map[string]any, offset, limit int) ([]T, error)
	Search(ctx context.Context, query *SearchQuery) (workerpool.JobResultPipe[[]T], error)
	Count(ctx context.Context) (int64, error)
	Save(ctx context.Context, entity T) error
	Delete(ctx context.Context, id string) error
}

BaseRepository provides generic CRUD operations for any model type. T is the model type (e.g., *models.Room).

func NewBaseRepository added in v1.61.0

func NewBaseRepository[T frame.BaseModelI](service *frame.Service, modelFactory func() T) BaseRepository[T]

NewBaseRepository creates a new base repository instance. modelFactory should return a pointer to a new model instance (e.g., func() *models.Room { return &models.Room{} }).

type Paginator

type Paginator struct {
	Offset int
	Limit  int

	BatchSize int
}

func (*Paginator) CanLoad

func (p *Paginator) CanLoad() bool

func (*Paginator) SetBatchSize

func (p *Paginator) SetBatchSize(batchSize int)

func (*Paginator) Stop

func (p *Paginator) Stop(loadedCount int) bool

type SearchQuery

type SearchQuery struct {
	ProfileID   string
	Query       string
	QueryFields map[string]string // We query with the value of query but use value as operator: {'id': ' = ?', 'name': ' LIKE ?', 'props': ' @@ plainto_tsquery(?)'}
	Fields      map[string]any

	Pagination *Paginator
}

func NewSearchQuery

func NewSearchQuery(query string,
	fields map[string]any,
	resultPage, resultCount int,
) *SearchQuery

Jump to

Keyboard shortcuts

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