query

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EventQueryOpts

func EventQueryOpts(q aggregate.Query) []query.Option

EventQueryOpts returns query.Options for a given aggregate.Query.

In order for the returned Query to return the correct events, EventQueryOpts needs to rewrite some of the version filters to make sense for an aggregate- specific event.Query:

  • version.Exact is rewritten to version.Max (querying for version 10 of an aggregate should return events 1 -> 10)
  • version.Max is passed without modification
  • version.Min is discarded (because an aggregate cannot start at a version > 1)
  • version.Ranges is rewritten to version.Max

func Test

func Test[D any](q aggregate.Query, a aggregate.Aggregate) bool

Test tests the aggregate a against the Query q and returns true if q should include a in its results. Test can be used by in-memory aggregate.Repository implementations to filter aggregates based on the query.

Types

type Option

type Option func(*builder)

Option is a query option.

func ID

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

ID returns an Option that filters aggregates by their ids.

func Name

func Name(names ...string) Option

Name returns an Option that filters aggregates by their names.

func SortBy

SortBy returns an Option that defines the sorting behaviour for a Query.

func SortByMulti

func SortByMulti(sorts ...aggregate.SortOptions) Option

SortByMulti returns an Option that defines the sorting behaviour for a Query.

func Version

func Version(constraints ...version.Option) Option

Version returns an Option that filters aggregates by their versions.

type Query

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

Query is used by aggregate repositories to filter aggregates.

func Merge

func Merge(queries ...aggregate.Query) Query

Merge merges multiple Queries into one.

func New

func New(opts ...Option) Query

New returns a Query that is built from opts.

func (Query) IDs

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

IDs returns the aggregate ids to query for.

func (Query) Names

func (q Query) Names() []string

Names returns the aggregate names to query for.

func (Query) Sortings

func (q Query) Sortings() []aggregate.SortOptions

Sortings returns the SortConfig for the query.

func (Query) Versions

func (q Query) Versions() version.Constraints

Versions returns the aggregate version constraints for the query.

type Tagger

type Tagger interface {
	HasTag(string) bool
}

Tagger is an aggregate that implements tagging.

Tagger is implemented by embedding *tagging.Tagger into an aggregate.

Jump to

Keyboard shortcuts

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