Documentation ¶
Overview ¶
Package query provides an event query builder.
Index ¶
- func Apply[D any](q event.Query, events ...event.Of[D]) []event.Of[D]
- func Test[D any](q event.Query, evt event.Of[D]) bool
- type Option
- func Aggregate(name string, id uuid.UUID) Option
- func AggregateID(ids ...uuid.UUID) Option
- func AggregateName(names ...string) Option
- func AggregateVersion(constraints ...version.Option) Option
- func Aggregates(aggregates ...event.AggregateRef) Option
- func ID(ids ...uuid.UUID) Option
- func Name(names ...string) Option
- func SortBy(sort event.Sorting, dir event.SortDirection) Option
- func SortByAggregate() Option
- func SortByMulti(sorts ...event.SortOptions) Option
- func SortByTime() Option
- func Time(constraints ...time.Option) Option
- type Query
- func (q Query) AggregateIDs() []uuid.UUID
- func (q Query) AggregateNames() []string
- func (q Query) AggregateVersions() version.Constraints
- func (q Query) Aggregates() []event.AggregateRef
- func (q Query) IDs() []uuid.UUID
- func (q Query) Names() []string
- func (q Query) Sortings() []event.SortOptions
- func (q Query) Times() time.Constraints
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*builder)
Option is an option for building a query.
func AggregateID ¶
AggregateID returns an Option that filters events by their aggregate ids.
func AggregateName ¶
AggregateName returns an Option that filters events by their aggregate names.
func AggregateVersion ¶
AggregateVersion returns an Option that filters events by their aggregate versions.
func Aggregates ¶
func Aggregates(aggregates ...event.AggregateRef) Option
Aggregates returns an Option that filters events by specific aggregates.
func SortBy ¶
func SortBy(sort event.Sorting, dir event.SortDirection) Option
SortBy returns an Option that sorts a Query by the given Sorting and SortDirection.
func SortByAggregate ¶
func SortByAggregate() Option
SortByAggregate returns an Option that sorts the a Query by aggregates.
Order of sortings is:
- aggregateName (ascending)
- aggregateID (ascending)
- aggregateVersion (ascending)
func SortByMulti ¶
func SortByMulti(sorts ...event.SortOptions) Option
SortByMulti return an Option that sorts a Query by multiple Sortings and SortDirections.
func SortByTime ¶
func SortByTime() Option
SortByTime returns an Option that sorts a Query by event time.
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
A Query is used by event stores to query events.
func Merge ¶
Merge merges multiple queries into a single query.
In cases where only a single value can be assigned to a filter, the last provided query that provides that filter is used.
func (Query) AggregateIDs ¶
AggregateIDs returns the aggregate ids to query for.
func (Query) AggregateNames ¶
AggregateNames returns the aggregate names to query for.
func (Query) AggregateVersions ¶
func (q Query) AggregateVersions() version.Constraints
AggregateVersions returns the aggregate versions to query for.
func (Query) Aggregates ¶
func (q Query) Aggregates() []event.AggregateRef
Aggregates returns a slice of specific aggregates to query for.
func (Query) Sortings ¶
func (q Query) Sortings() []event.SortOptions
Sortings returns the sorting options for the query.
func (Query) Times ¶
func (q Query) Times() time.Constraints
Time returns the time constraints. The returned Constraints are guaranteed to be non-nil.