query

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Overview

Package query provides an event query builder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply[D any](q event.Query, events ...event.Of[D]) []event.Of[D]

Apply tests events against the provided Query and returns only those events that match the Query.

func Test

func Test[D any](q event.Query, evt event.Of[D]) bool

Test tests the event evt against the Query q and returns true if q should include evt in its results. Test can be used by in-memory event.Store implementations to filter events based on the query.

Types

type Option

type Option func(*builder)

Option is an option for building a query.

func Aggregate

func Aggregate(name string, id uuid.UUID) Option

Aggregate returns an Option that filters events by a specific aggregate.

func AggregateID

func AggregateID(ids ...uuid.UUID) Option

AggregateID returns an Option that filters events by their aggregate ids.

func AggregateName

func AggregateName(names ...string) Option

AggregateName returns an Option that filters events by their aggregate names.

func AggregateVersion

func AggregateVersion(constraints ...version.Option) Option

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 ID

func ID(ids ...uuid.UUID) Option

ID returns an Option that filters events by their ids.

func Name

func Name(names ...string) Option

Name returns an Option that filters events by their names.

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:

  1. aggregateName (ascending)
  2. aggregateID (ascending)
  3. 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.

func Time

func Time(constraints ...time.Option) Option

Time returns an Option that filters events by time constraints.

type Query

type Query struct {
	// contains filtered or unexported fields
}

A Query is used by event stores to query events.

func Merge

func Merge(queries ...event.Query) Query

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 New

func New(opts ...Option) Query

New builds the query from the provided options.

func (Query) AggregateIDs

func (q Query) AggregateIDs() []uuid.UUID

AggregateIDs returns the aggregate ids to query for.

func (Query) AggregateNames

func (q Query) AggregateNames() []string

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) IDs

func (q Query) IDs() []uuid.UUID

IDs returns the event ids to query for.

func (Query) Names

func (q Query) Names() []string

Names returns the event names 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.

Directories

Path Synopsis
Package time provides time constraints for queries.
Package time provides time constraints for queries.
Package version provides version constraints for queries.
Package version provides version constraints for queries.

Jump to

Keyboard shortcuts

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