Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EventQueryOpts ¶
EventQueryOpts is typically used to convert the aggregate query into a query that can be passed to an event store.
func Test ¶
Test filters an aggregate based on the criteria specified in the provided aggregate query. It checks if the name, ID, and version of the aggregate match the names, IDs, and versions specified in the query. If the aggregate also implements the Tagger interface and the query includes tags, Test checks if any of those tags are associated with the aggregate. Test returns true if all checks pass, otherwise it returns false.
Types ¶
type Option ¶
type Option func(*Query)
Option is a function type that modifies a Query. It is typically used to fine-tune the behavior of a Query, such as specifying the names, IDs, version constraints, or sorting options that the Query should filter by. By default, an Option has no effect on the Query unless explicitly provided during the creation of the Query. Options can be combined and ordered in any way, providing flexible control over how a Query operates.
func ID ¶
ID is an option for a Query that specifies a slice of UUIDs to filter Aggregates by. The provided UUIDs are added to the Query's existing list of IDs, with any duplicates being ignored. Only Aggregates with an ID present in this list will be considered when processing the Query.
func Name ¶
Name adds provided names to the aggregate names that a Query targets. It ensures that each name is unique within the Query. If a name already exists in the Query, it will not be added again. The function returns an Option to be used with New or other functions that accept Options.
func SortBy ¶
func SortBy(sort aggregate.Sorting, dir aggregate.SortDirection) Option
SortBy sets the sorting options for a Query. It determines how the Aggregates that match the Query will be sorted. SortBy takes a sort parameter of type aggregate.Sorting to specify the field to sort by, and a direction parameter of type aggregate.SortDirection to specify the direction of sorting. It returns an Option that can be used to build or modify a Query.
func SortByMulti ¶
func SortByMulti(sorts ...aggregate.SortOptions) Option
SortByMulti appends multiple sort options to a Query. It allows the sorting of aggregates in a Query based on multiple criteria. This function is an Option type, meaning it modifies the state of a Query when passed into the New function. The sort options are specified by providing one or more instances of aggregate.SortOptions.
func Version ¶
Version appends the provided version constraints to the version constraints of a Query. The constraints are used to filter aggregates based on their versions when processing the Query. The function accepts an arbitrary number of version.Option as its parameters. These options define the exact, minimum, maximum, or range of versions that an aggregate must have in order to match the Query.
type Q ¶ added in v0.4.3
type Q struct { Names []string IDs []uuid.UUID Versions version.Constraints Sortings []aggregate.SortOptions }
Q is a struct that represents a filter for aggregates based on their name, ID, version, and sorting options. It provides a way to selectively process aggregates that match specified criteria. This type is used in the construction of a Query and contains fields for Names, IDs, Versions, and Sortings.
type Query ¶
type Query struct { Q // contains filtered or unexported fields }
Query represents a set of criteria for filtering aggregates based on their name, ID, version, and sorting options. This type is used to selectively process aggregates that meet the specified conditions. It contains fields for Names, IDs, Versions, and Sortings which are defined by the Q struct.
Furthermore, it allows modification through Option functions to fine-tune the behavior of a Query, such as specifying names, IDs, version constraints or sorting options. It also provides methods to merge multiple queries into one or expand an aggregate.Query into a Query. Also included are methods to add names, IDs, version constraints and sorting options to the Query.
In addition to these functionalities, Query also works with Tagger to determine whether a specific tag is associated with an aggregate.
func Expand ¶ added in v0.4.3
Expand converts an aggregate.Query into a Query. If the provided aggregate.Query is already a Query, it is returned unchanged. Otherwise, a new Query is created with the names, IDs, version constraints and sorting options of the provided aggregate.Query.
func Merge ¶
Merge combines multiple aggregate queries into a single query. The resulting query includes the names, IDs, and version constraints of each provided query. The returned query can be used to filter aggregates that match any of the criteria specified in the merged queries.
func New ¶
New constructs a new Query with the provided options. The options can specify names, IDs, version constraints, and sorting options to fine-tune the behavior of the Query. If no options are provided, it returns an empty Query.
func (Query) Sortings ¶
func (q Query) Sortings() []aggregate.SortOptions
Sortings returns the sorting options of the Query. The returned sort options determine the order in which Aggregates should be sorted when processing the Query.
func (Query) Versions ¶
func (q Query) Versions() version.Constraints
Versions returns the version constraints of the Query, which are used to filter aggregates based on their versions.
type Tagger ¶
type Tagger interface { // HasTag checks if a given tag is associated with the [Tagger] interface. It // returns true if the tag exists, and false otherwise. HasTag(string) bool }
Tagger is an interface that provides a method for determining if a specific tag is associated with an object. It's primarily used in the context of aggregate queries, where it can be implemented to filter out aggregates based on their tagging.