Documentation ¶
Index ¶
- Constants
- type AggregationGroup
- type AggregationItem
- type AggregationItems
- type Aggregations
- type AndCriteria
- type BaseSubQuery
- type Callback
- type CallbackContext
- type Criteria
- type DaoCriteria
- type DbContext
- type DbCriteria
- type Facet
- type FacetConfig
- type FacetContext
- type FacetFilter
- type FacetOption
- func FacetHasAggregationOption(options ...Option) FacetOption
- func FacetHasFilter(filter FacetFilter) FacetOption
- func FacetHasKey(key string) FacetOption
- func FacetHasLabel(label string) FacetOption
- func FacetIsAggregated() FacetOption
- func FacetTriggersCte() FacetOption
- func FacetUsesAndLogic() FacetOption
- func FacetUsesLogic(logic model.FacetLogic) FacetOption
- func FacetUsesOrLogic() FacetOption
- type GenCriteria
- type GenericResult
- type GenericSubQuery
- type GormScope
- type HasManyHydrator
- type HasOneHydrator
- type NotCriteria
- type Option
- func CacheMode(mode cache.Mode) Option
- func CacheWarm() Option
- func Cached() Option
- func Context(fn func(ctx context.Context) context.Context) Option
- func DefaultOption() Option
- func Group(columns ...clause.Column) Option
- func HydrateHasMany[Root any, RootID comparable, JoinSub any, Sub any](h HasManyHydrator[Root, RootID, JoinSub, Sub]) Option
- func HydrateHasOne[Root any, Sub any, SubID comparable](h HasOneHydrator[Root, Sub, SubID]) Option
- func Join(fn func(*dao.Query) []TableJoin) Option
- func Limit(n uint) Option
- func Offset(n uint) Option
- func Options(o ...Option) Option
- func OrderBy(columns ...OrderByColumn) Option
- func OrderByQueryStringRank() Option
- func Preload(fn func(query *dao.Query) []field.RelationField) Option
- func QueryString(str string) Option
- func RequireJoin(names ...string) Option
- func Select(columns ...clause.Expr) Option
- func SelectAll() Option
- func Table(name string) Option
- func Where(conditions ...Criteria) Option
- func WithAggregationBudget(budget float64) Option
- func WithFacet(facets ...Facet) Option
- func WithHasNextPage(bl bool) Option
- func WithTotalCount(bl bool) Option
- type OptionBuilder
- type OrCriteria
- type OrderByColumn
- type RawCriteria
- type RawJoin
- type ResultItem
- type Scope
- type SearchParams
- type SubQuery
- type SubQueryFactory
- type TableJoin
- type TableJoinType
Constants ¶
View Source
const QueryStringRankField = "query_string_rank"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregationGroup ¶
type AggregationGroup struct { Label string Logic model.FacetLogic Items AggregationItems }
type AggregationItem ¶
type AggregationItems ¶
type AggregationItems = map[string]AggregationItem
type Aggregations ¶
type Aggregations = maps.StringMap[AggregationGroup]
type AndCriteria ¶
type AndCriteria struct {
Criteria []Criteria
}
func (AndCriteria) Raw ¶
func (c AndCriteria) Raw(ctx DbContext) (RawCriteria, error)
type BaseSubQuery ¶
type CallbackContext ¶
type CallbackContext interface { DbContext Lock() Unlock() }
type Criteria ¶
type Criteria interface {
Raw(c DbContext) (RawCriteria, error)
}
func QueryStringCriteria ¶
type DaoCriteria ¶
type DaoCriteria struct { Conditions func(ctx DbContext) ([]field.Expr, error) Joins maps.InsertMap[string, struct{}] }
func (DaoCriteria) Raw ¶
func (c DaoCriteria) Raw(ctx DbContext) (RawCriteria, error)
type DbCriteria ¶
type DbCriteria struct { Sql string Args []interface{} }
func (DbCriteria) Raw ¶
func (c DbCriteria) Raw(ctx DbContext) (RawCriteria, error)
type Facet ¶
type Facet interface { FacetConfig Values(ctx FacetContext) (map[string]string, error) Criteria(filter FacetFilter) []Criteria }
type FacetConfig ¶
type FacetConfig interface { Key() string Label() string Logic() model.FacetLogic Filter() FacetFilter IsAggregated() bool AggregationOption(b OptionBuilder) (OptionBuilder, error) TriggersCte() bool }
func NewFacetConfig ¶
func NewFacetConfig(options ...FacetOption) FacetConfig
type FacetContext ¶
type FacetFilter ¶
type FacetFilter map[string]struct{}
func (FacetFilter) HasKey ¶ added in v0.6.0
func (f FacetFilter) HasKey(key string) bool
func (FacetFilter) Values ¶
func (f FacetFilter) Values() []string
Values allows iteration over deterministically sorted filter values, which helps with query caching.
type FacetOption ¶
type FacetOption func(facetConfig) facetConfig
func FacetHasAggregationOption ¶
func FacetHasAggregationOption(options ...Option) FacetOption
func FacetHasFilter ¶
func FacetHasFilter(filter FacetFilter) FacetOption
func FacetHasKey ¶
func FacetHasKey(key string) FacetOption
func FacetHasLabel ¶
func FacetHasLabel(label string) FacetOption
func FacetIsAggregated ¶
func FacetIsAggregated() FacetOption
func FacetTriggersCte ¶ added in v0.9.0
func FacetTriggersCte() FacetOption
func FacetUsesAndLogic ¶
func FacetUsesAndLogic() FacetOption
func FacetUsesLogic ¶
func FacetUsesLogic(logic model.FacetLogic) FacetOption
func FacetUsesOrLogic ¶
func FacetUsesOrLogic() FacetOption
type GenCriteria ¶
func (GenCriteria) Raw ¶
func (c GenCriteria) Raw(ctx DbContext) (RawCriteria, error)
type GenericResult ¶
type GenericResult[T interface{}] struct { TotalCount uint TotalCountIsEstimate bool HasNextPage bool Items []T Aggregations Aggregations }
func GenericQuery ¶
func GenericQuery[T interface{}]( _ctx context.Context, daoQ *dao.Query, option Option, tableName string, factory SubQueryFactory, ) (GenericResult[T], error)
GenericQuery executes queries for any type of search and returns a GenericResult
type GenericSubQuery ¶
type GenericSubQuery[T BaseSubQuery] struct { SubQuery BaseSubQuery }
func (GenericSubQuery[T]) Count ¶
func (sq GenericSubQuery[T]) Count() (int64, error)
func (GenericSubQuery[T]) TableName ¶
func (sq GenericSubQuery[T]) TableName() string
func (GenericSubQuery[T]) UnderlyingDB ¶
func (sq GenericSubQuery[T]) UnderlyingDB() *gorm.DB
type HasManyHydrator ¶
type HasOneHydrator ¶
type NotCriteria ¶
type NotCriteria struct {
Criteria []Criteria
}
func (NotCriteria) Raw ¶
func (c NotCriteria) Raw(ctx DbContext) (RawCriteria, error)
type Option ¶
type Option = func(ctx OptionBuilder) (OptionBuilder, error)
func DefaultOption ¶
func DefaultOption() Option
func HydrateHasMany ¶
func HydrateHasMany[Root any, RootID comparable, JoinSub any, Sub any](h HasManyHydrator[Root, RootID, JoinSub, Sub]) Option
func HydrateHasOne ¶
func HydrateHasOne[Root any, Sub any, SubID comparable](h HasOneHydrator[Root, Sub, SubID]) Option
func OrderBy ¶
func OrderBy(columns ...OrderByColumn) Option
func OrderByQueryStringRank ¶
func OrderByQueryStringRank() Option
func QueryString ¶
func RequireJoin ¶
func WithAggregationBudget ¶ added in v0.6.0
func WithHasNextPage ¶ added in v0.4.0
func WithTotalCount ¶
type OptionBuilder ¶
type OptionBuilder interface { DbContext Table(string) OptionBuilder Join(...TableJoin) OptionBuilder RequireJoin(...string) OptionBuilder QueryString(string) OptionBuilder Scope(...Scope) OptionBuilder Select(...clause.Expr) OptionBuilder OrderBy(...OrderByColumn) OptionBuilder Limit(uint) OptionBuilder Offset(uint) OptionBuilder Group(...clause.Column) OptionBuilder Facet(...Facet) OptionBuilder Preload(...field.RelationField) OptionBuilder Callback(...Callback) OptionBuilder Context(func(ctx context.Context) context.Context) OptionBuilder WithTotalCount(bool) OptionBuilder WithHasNextPage(bool) OptionBuilder WithAggregationBudget(float64) OptionBuilder AggregationBudget() float64 // contains filtered or unexported methods }
type OrCriteria ¶
type OrCriteria struct {
Criteria []Criteria
}
func (OrCriteria) Raw ¶
func (c OrCriteria) Raw(ctx DbContext) (RawCriteria, error)
type OrderByColumn ¶
type OrderByColumn struct { clause.OrderByColumn RequiredJoins []string }
type RawCriteria ¶
type RawCriteria struct { Query interface{} Args []interface{} Joins maps.InsertMap[string, struct{}] }
func (RawCriteria) Raw ¶
func (c RawCriteria) Raw(ctx DbContext) (RawCriteria, error)
type ResultItem ¶
type ResultItem struct {
QueryStringRank float64
}
type SearchParams ¶
type SearchParams struct { QueryString model.NullString Limit model.NullUint Offset model.NullUint TotalCount model.NullBool HasNextPage model.NullBool Cached model.NullBool AggregationBudget model.NullFloat64 }
func (SearchParams) Option ¶
func (s SearchParams) Option() Option
type SubQuery ¶
type SubQuery interface { BaseSubQuery Scopes(...GormScope) SubQuery }
type TableJoinType ¶
type TableJoinType int
const ( TableJoinTypeInner TableJoinType = iota TableJoinTypeLeft TableJoinTypeRight )
Source Files ¶
Click to show internal directories.
Click to hide internal directories.