Documentation ¶
Index ¶
- func NewEvent[I repo.ID]() repo.Event[I]
- func NewRepoOptions[I repo.ID, A dgo.AggBase, D any]() *repoOptions[I, A, D]
- func NewVid[I repo.ID](id I, version uint64) repo.Vid[I]
- func PrintRepoOptions(packageName string)
- func ReplaceError(err error) error
- type Aggregate
- type Content
- type DefaultContent
- func (c *DefaultContent[D]) GetCreatedAt() time.Time
- func (c *DefaultContent[D]) GetData() D
- func (c *DefaultContent[D]) GetUpdatedAt() time.Time
- func (c *DefaultContent[D]) GetVersion() uint64
- func (c *DefaultContent[D]) SetCreatedAt(t time.Time)
- func (c *DefaultContent[D]) SetData(d D)
- func (c *DefaultContent[D]) SetUpdatedAt(t time.Time)
- func (c *DefaultContent[D]) SetVersion(version uint64)
- type Repo
- func (r *Repo[I, A, D]) Agg() *mg.Collection
- func (r *Repo[I, A, D]) DA2PA(ctx context.Context, da A) (Aggregate[I, D], error)
- func (r *Repo[I, A, D]) DB() *mg.Database
- func (r *Repo[I, A, D]) Delete(ctx context.Context, a A) error
- func (r *Repo[I, A, D]) Event() *mg.Collection
- func (r *Repo[I, A, D]) FindDA(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (d A, err error)
- func (r *Repo[I, A, D]) FindDAs(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (das []A, err error)
- func (r *Repo[I, A, D]) FindPA(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (Aggregate[I, D], error)
- func (r *Repo[I, A, D]) FindPAs(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (pas []Aggregate[I, D], err error)
- func (r *Repo[I, A, D]) Get(ctx context.Context, id dgo.ID) (a A, err error)
- func (r *Repo[I, A, D]) List(ctx context.Context, ids ...dgo.ID) (as []A, err error)
- func (r *Repo[I, A, D]) PA2DA(ctx context.Context, pa Aggregate[I, D]) (A, error)
- func (r *Repo[I, A, D]) ParseID(id dgo.ID) (I, error)
- func (r *Repo[I, A, D]) Save(ctx context.Context, a A) error
- func (r *Repo[I, A, D]) SaveEvents(ctx context.Context, unsaved dgo.Events) error
- func (_r *Repo[I, A, D]) SetOptions(_opts ...RepoOption[I, A, D]) *Repo[I, A, D]
- func (r *Repo[I, A, D]) Transaction(ctx context.Context, fn func(ctx context.Context, r dgo.Repo[A]) error) error
- func (r *Repo[I, A, D]) VersionFieldName() string
- type RepoOption
- func SkipRepoOption[I repo.ID, A dgo.AggBase, D any]() RepoOption[I, A, D]
- func WithRepoCloseTransaction[I repo.ID, A dgo.AggBase, D any](closeTransaction bool) RepoOption[I, A, D]
- func WithRepoGetVid[I repo.ID, A dgo.AggBase, D any](getVid repo.NewVid[I]) RepoOption[I, A, D]
- func WithRepoNewAggregate[I repo.ID, A dgo.AggBase, D any](newAggregate func() Aggregate[I, D]) RepoOption[I, A, D]
- func WithRepoNewEvent[I repo.ID, A dgo.AggBase, D any](newEvent func() repo.Event[I]) RepoOption[I, A, D]
- func WithRepoOptions[I repo.ID, A dgo.AggBase, D any](o *repoOptions[I, A, D]) RepoOption[I, A, D]
- func WithRepoVersionFieldName[I repo.ID, A dgo.AggBase, D any](versionFieldName string) RepoOption[I, A, D]
- type Time
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRepoOptions ¶
NewRepoOptions[I repo.ID,A dgo.AggBase,D any] new options struct
func PrintRepoOptions ¶
func PrintRepoOptions(packageName string)
func ReplaceError ¶
Types ¶
type Aggregate ¶
type DefaultContent ¶
type DefaultContent[D any] struct { CreatedAt Time `bson:"createdAt"` UpdatedAt Time `bson:"updatedAt"` Version uint64 `bson:"version"` Data D `bson:",inline"` }
func (*DefaultContent[D]) GetCreatedAt ¶
func (c *DefaultContent[D]) GetCreatedAt() time.Time
func (*DefaultContent[D]) GetData ¶
func (c *DefaultContent[D]) GetData() D
func (*DefaultContent[D]) GetUpdatedAt ¶
func (c *DefaultContent[D]) GetUpdatedAt() time.Time
func (*DefaultContent[D]) GetVersion ¶
func (c *DefaultContent[D]) GetVersion() uint64
func (*DefaultContent[D]) SetCreatedAt ¶
func (c *DefaultContent[D]) SetCreatedAt(t time.Time)
func (*DefaultContent[D]) SetData ¶
func (c *DefaultContent[D]) SetData(d D)
func (*DefaultContent[D]) SetUpdatedAt ¶
func (c *DefaultContent[D]) SetUpdatedAt(t time.Time)
func (*DefaultContent[D]) SetVersion ¶
func (c *DefaultContent[D]) SetVersion(version uint64)
type Repo ¶
func NewDefaultRepo ¶
func NewRepo ¶
func NewRepo[I repo.ID, A dgo.AggBase, D any](db *mg.Database, agg, event *mg.Collection, convert func(context.Context, A) (D, error), reverse func(context.Context, dgo.AggBase, D) (A, error), newData func() D, parseID repo.ParseID[I], _opts ...RepoOption[I, A, D]) *Repo[I, A, D]
NewRepo constructor
func (*Repo[I, A, D]) Agg ¶
func (r *Repo[I, A, D]) Agg() *mg.Collection
func (*Repo[I, A, D]) Event ¶
func (r *Repo[I, A, D]) Event() *mg.Collection
func (*Repo[I, A, D]) SaveEvents ¶
func (*Repo[I, A, D]) SetOptions ¶
func (_r *Repo[I, A, D]) SetOptions(_opts ...RepoOption[I, A, D]) *Repo[I, A, D]
func (*Repo[I, A, D]) Transaction ¶
func (*Repo[I, A, D]) VersionFieldName ¶
type RepoOption ¶
type RepoOption[I repo.ID, A dgo.AggBase, D any] interface { // contains filtered or unexported methods }
RepoOption[I repo.ID,A dgo.AggBase,D any] option interface
func SkipRepoOption ¶
func WithRepoCloseTransaction ¶
func WithRepoCloseTransaction[I repo.ID, A dgo.AggBase, D any](closeTransaction bool) RepoOption[I, A, D]
WithRepoCloseTransaction closeTransaction option of Repo
func WithRepoGetVid ¶
WithRepoGetVid getVid option of Repo
func WithRepoNewAggregate ¶
func WithRepoNewAggregate[I repo.ID, A dgo.AggBase, D any](newAggregate func() Aggregate[I, D]) RepoOption[I, A, D]
WithRepoNewAggregate newAggregate option of Repo
func WithRepoNewEvent ¶
func WithRepoNewEvent[I repo.ID, A dgo.AggBase, D any](newEvent func() repo.Event[I]) RepoOption[I, A, D]
WithRepoNewEvent newEvent option of Repo
func WithRepoOptions ¶
func WithRepoVersionFieldName ¶
func WithRepoVersionFieldName[I repo.ID, A dgo.AggBase, D any](versionFieldName string) RepoOption[I, A, D]
WithRepoVersionFieldName versionFieldName option of Repo
Click to show internal directories.
Click to hide internal directories.