indices

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: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EventStore = EventStoreIndices{
	ID: mongo.IndexModel{
		Keys:    bson.D{{Key: "id", Value: 1}},
		Options: options.Index().SetName("goes_id").SetUnique(true),
	},

	Name: mongo.IndexModel{Keys: bson.D{{Key: "name", Value: 1}}},

	NameAndTime: mongo.IndexModel{
		Keys: bson.D{
			{Key: "name", Value: 1},
			{Key: "timeNano", Value: 1},
		},
		Options: options.Index().SetName("goes_name_time"),
	},

	AggregateNameAndVersion: mongo.IndexModel{
		Keys: bson.D{
			{Key: "aggregateName", Value: 1},
			{Key: "aggregateVersion", Value: 1},
		},
		Options: options.Index().SetName("goes_aname_aversion"),
	},

	AggregateNameAndIDAndVersion: mongo.IndexModel{
		Keys: bson.D{
			{Key: "aggregateName", Value: 1},
			{Key: "aggregateId", Value: 1},
			{Key: "aggregateVersion", Value: 1},
		},
		Options: options.Index().SetName("goes_aname_aid_aversion").
			SetUnique(true).
			SetPartialFilterExpression(bson.D{
				{Key: "aggregateName", Value: bson.D{{Key: "$exists", Value: true}, {Key: "$gt", Value: ""}}},
				{Key: "aggregateId", Value: bson.D{{Key: "$exists", Value: true}, {Key: "$gt", Value: uuid.UUID{}}}},
				{Key: "aggregateVersion", Value: bson.D{{Key: "$exists", Value: true}, {Key: "$gt", Value: 0}}},
			}),
	},

	AggregateID: mongo.IndexModel{
		Keys:    bson.D{{Key: "aggregateId", Value: 1}},
		Options: options.Index().SetName("goes_aid"),
	},

	AggregateVersion: mongo.IndexModel{
		Keys:    bson.D{{Key: "aggregateVersion", Value: 1}},
		Options: options.Index().SetName("goes_aversion"),
	},

	NameAndVersion: mongo.IndexModel{
		Keys: bson.D{
			{Key: "name", Value: 1},
			{Key: "aggregateVersion", Value: 1},
		},
		Options: options.Index().SetName("goes_name_aversion"),
	},
}

EventStore provides the builtin index models for the MongoDB event store.

Functions

func EventStoreCore

func EventStoreCore() []mongo.IndexModel

EventStoreCore returns the core index models for the MongoDB event store.

func EventStoreEdge

func EventStoreEdge() []mongo.IndexModel

EventStoreEdge returns all edge-case index models for the MongoDB event store.

Types

type EventStoreIndices

type EventStoreIndices struct {

	// ID creates an index for the event id.
	ID mongo.IndexModel

	// Name creates an index for the event name.
	Name mongo.IndexModel

	// NameAndTime creates a compound index for the event name and id.
	NameAndTime mongo.IndexModel

	// AggregateNameAndVersion creates a compound index for the aggregate name and version.
	AggregateNameAndVersion mongo.IndexModel

	// AggregateNameAndIDAndVersion creates a compound index for the aggregate name, id, and version.
	AggregateNameAndIDAndVersion mongo.IndexModel

	// ISOTime creates an index for the ISO time field. Usually, this is not
	// needed because an index is already created for the nano time field.
	ISOTime mongo.IndexModel

	// AggregateID creates an index for the aggregate id.
	AggregateID mongo.IndexModel

	// AggregateVersion creates an index for the aggregate version.
	AggregateVersion mongo.IndexModel

	// NameAndVersion creates a compound index for the event name and version.
	NameAndVersion mongo.IndexModel
}

EventStoreIndices provides the builtin index models for the MongoDB event store.

Jump to

Keyboard shortcuts

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