mongo

package
v0.0.0-...-150cbac Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(host string, port int, db string) (eventhus.EventStore, error)

NewClient generates a new client to access to mongodb

Types

type AggregateDB

type AggregateDB struct {
	ID      string    `bson:"_id"`
	Version int       `bson:"version"`
	Events  []EventDB `bson:"events"`
}

AggregateDB defines the collection to store the aggregate with their events

type Client

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

Client for access to mongodb

func (*Client) Load

func (c *Client) Load(aggregateID string) ([]eventhus.Event, error)

Load the stored events for an AggregateID

func (*Client) SafeSave

func (c *Client) SafeSave(events []eventhus.Event, version int) error

SafeSave store the events without check the current version

func (*Client) Save

func (c *Client) Save(events []eventhus.Event, version int) error

Save the events ensuring the current version

type EventDB

type EventDB struct {
	Type        string   `bson:"event_type"`
	AggregateID string   `bson:"_id"`
	RawData     bson.Raw `bson:"data,omitempty"`

	Timestamp     time.Time `bson:"timestamp"`
	AggregateType string    `bson:"aggregate_type"`
	Version       int       `bson:"version"`
	// contains filtered or unexported fields
}

EventDB defines the structure of the events to be stored

Jump to

Keyboard shortcuts

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