Documentation ¶
Index ¶
- Variables
- type Option
- type Store
- func (s *Store) Connect(ctx context.Context) (*mongo.Client, error)
- func (s *Store) Delete(ctx context.Context, snap snapshot.Snapshot) error
- func (s *Store) Latest(ctx context.Context, name string, id uuid.UUID) (snapshot.Snapshot, error)
- func (s *Store) Limit(ctx context.Context, name string, id uuid.UUID, v int) (snapshot.Snapshot, error)
- func (s *Store) Query(ctx context.Context, q snapshot.Query) (<-chan snapshot.Snapshot, <-chan error, error)
- func (s *Store) Save(ctx context.Context, snap snapshot.Snapshot) error
- func (s *Store) Version(ctx context.Context, name string, id uuid.UUID, version int) (snapshot.Snapshot, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned when a Snapshot can't be found in the database. ErrNotFound = errors.New("snapshot not found") )
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Store)
Option is a Store option.
func Collection ¶
Collection returns an Option that specifies the collection name for Snapshots.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the MongoDB implementation of snapshot.Store.
func (*Store) Connect ¶
Connect establishes the connection to the underlying MongoDB and returns the mongo.Client. Connect doesn't need to be called manually as it's called automatically on the first call to s.Save, s.Latest, s.Version, s.Query or s.Delete. Use Connect if you want to explicitly control when to connect to MongoDB.
func (*Store) Latest ¶
Latest returns the latest Snapshot for the Aggregate with the given name and UUID or ErrNotFound if no Snapshots for that Aggregate exist in the database.
func (*Store) Limit ¶
func (s *Store) Limit(ctx context.Context, name string, id uuid.UUID, v int) (snapshot.Snapshot, error)
Limit returns the latest Snapshot that has a version equal to or lower than the given version.
Limit returns ErrNotFound if no such Snapshot can be found in the database.