Documentation ¶
Index ¶
- Constants
- Variables
- type EventStore
- func (s *EventStore) Clear(ctx context.Context) error
- func (s *EventStore) Close(ctx context.Context)
- func (s *EventStore) Load(ctx context.Context, id uuid.UUID) ([]eh.Event, error)
- func (s *EventStore) RenameEvent(ctx context.Context, from, to eh.EventType) error
- func (s *EventStore) Replace(ctx context.Context, event eh.Event) error
- func (s *EventStore) Save(ctx context.Context, events []eh.Event, originalVersion int) error
- type Repo
- func (r *Repo) Find(ctx context.Context, id uuid.UUID) (eh.Entity, error)
- func (r *Repo) FindAll(ctx context.Context) ([]eh.Entity, error)
- func (r *Repo) FindCustom(ctx context.Context, callback func(*firestore.CollectionRef) *firestore.Query) ([]interface{}, error)
- func (r *Repo) FindCustomIter(ctx context.Context, callback func(*firestore.CollectionRef) *firestore.Query) (eh.Iter, error)
- func (r *Repo) Parent() eh.ReadRepo
- func (r *Repo) Remove(ctx context.Context, id uuid.UUID) error
- func (r *Repo) Save(ctx context.Context, entity eh.Entity) error
- func (r *Repo) SetEntityFactory(f func() eh.Entity)
Constants ¶
const ( // FieldCreated the name of the field tracking when an entity was created FieldCreated = "_created" // FieldUpdated the name of the field tracking when an entity was updated FieldUpdated = "_updated" )
Variables ¶
var ( // ErrCouldNotSaveAggregate is when an aggregate could not be saved. ErrCouldNotSaveAggregate = errors.New("could not save aggregate") // ErrCouldNotUnmarshalAggregate is when an aggregate could not be unmarshaled into a concrete type. ErrCouldNotUnmarshalAggregate = errors.New("could not unmarshal aggregate") // ErrCouldNotMarshalEvent is when an event could not be marshaled into JSON ErrCouldNotMarshalEvent = errors.New("could not marshal event") // ErrCouldNotUnmarshalEvent is when an event could not be unmarshaled into a concrete type. ErrCouldNotUnmarshalEvent = errors.New("could not unmarshal event") )
var ErrCouldNotConvertData = errors.New("could not convert data")
ErrCouldNotConvertData is when data could not be converted
var ErrCouldNotDialDB = errors.New("could not dial database")
ErrCouldNotDialDB is when the database could not be dialed.
var ErrInvalidQuery = errors.New("invalid query")
ErrInvalidQuery is when a query was not returned from the callback to FindCustom.
var ErrModelNotSet = errors.New("model not set")
ErrModelNotSet is when an model factory is not set on the Repo.
var ErrNoDBClient = errors.New("no database client")
ErrNoDBClient is when no database client is set.
Functions ¶
This section is empty.
Types ¶
type EventStore ¶
type EventStore struct {
// contains filtered or unexported fields
}
EventStore implements an EventStore for Firestore
func NewEventStore ¶
func NewEventStore(projectID, prefix string, opts ...option.ClientOption) (*EventStore, error)
NewEventStore creates a new EventStore with optional GCP connection settings
func NewEventStoreWithClient ¶
func NewEventStoreWithClient(prefix string, client *firestore.Client) *EventStore
NewEventStoreWithClient creates a new EventStore with DB
func (*EventStore) Close ¶
func (s *EventStore) Close(ctx context.Context)
func (*EventStore) RenameEvent ¶
RenameEvent implements the RenameEvent method of the eventhorizon.EventStore interface.
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo implements a Cloud Firestore repository for entities
func NewRepo ¶
func NewRepo(projectID, collection string, opts ...option.ClientOption) (*Repo, error)
NewRepo created a new Repo.
func NewRepoWithClient ¶
NewRepoWithClient created a new Repo with a client.
func (*Repo) FindCustom ¶
func (r *Repo) FindCustom(ctx context.Context, callback func(*firestore.CollectionRef) *firestore.Query) ([]interface{}, error)
FindCustom uses a callback to specify a custom query for returning models. It can also be used to do queries that do not map to the model by executing the query in the callback and returning nil to block the second execution of the same query in FindCustom. Expect a ErrInvalidQuery if returning a nil query from the callback
func (*Repo) FindCustomIter ¶
func (r *Repo) FindCustomIter(ctx context.Context, callback func(*firestore.CollectionRef) *firestore.Query) (eh.Iter, error)
FindCustomIter returns a curser you can use to stream results of very large datasets
func (*Repo) SetEntityFactory ¶
SetEntityFactory sets a factory function that creates concrete entity types.