Documentation
¶
Index ¶
- Variables
- type Option
- type Querier
- type Repo
- func (r *Repo[T]) Clear(ctx context.Context) error
- func (r *Repo[T]) Close() error
- func (r *Repo[T]) Find(ctx context.Context, id uuid.UUID) (eh.Entity, error)
- func (r *Repo[T]) FindAll(ctx context.Context) ([]eh.Entity, error)
- func (r *Repo[T]) InnerRepo(ctx context.Context) eh.ReadRepo
- func (r *Repo[T]) Remove(ctx context.Context, id uuid.UUID) error
- func (r *Repo[T]) Save(ctx context.Context, entity eh.Entity) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInsertInsteadOfUpsert = errors.New("insert instead of upsert") ErrInsertNotImplemented = errors.New("insert not implemented") )
View Source
var ( // ErrModelNotSet is when a model factory is not set on the Repo. ErrModelNotSet = errors.New("model not set") )
Functions ¶
This section is empty.
Types ¶
type Option ¶
Option is an option setter used to configure creation.
func WithConnectionCheck ¶
func WithConnectionCheck[T eh.Entity](h eh.EventHandler) Option[T]
WithConnectionCheck adds an optional DB connection check when calling New().
type Repo ¶
Repo implements an MongoDB repository for entities.
func IntoRepo ¶
IntoRepo tries to convert a eh.ReadRepo into a Repo by recursively looking at inner repos. Returns nil if none was found.
func NewRepo ¶
func NewRepo[T eh.Entity](ctx context.Context, uri, table string, initQuerier func(*pgxpool.Pool) Querier[T], options ...Option[T]) (*Repo[T], error)
NewRepo creates a new Repo.
func NewRepoWithConnPool ¶
func NewRepoWithConnPool[T eh.Entity](connPool *pgxpool.Pool, table string, initQuerier func(*pgxpool.Pool) Querier[T], options ...Option[T]) (*Repo[T], error)
NewRepoWithClient creates a new Repo with a client.
func (*Repo[T]) FindAll ¶
FindAll implements the FindAll method of the eventhorizon.ReadRepo interface.
func (*Repo[T]) InnerRepo ¶
InnerRepo implements the InnerRepo method of the eventhorizon.ReadRepo interface.
Click to show internal directories.
Click to hide internal directories.