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 ¶
func (*Paginator) SetBatchSize ¶
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
Click to show internal directories.
Click to hide internal directories.