mocks

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DbRepo

type DbRepo[T repos.Entity] struct {
	Calls                      map[string][]DbRepoCallerInfo
	MockCount                  func(ctx context.Context, filter repos.Filter) (int64, error)
	MockCreate                 func(ctx context.Context, data T) (T, error)
	MockCreateMany             func(ctx context.Context, data []T) error
	MockDeleteById             func(ctx context.Context, id repos.ID) error
	MockDeleteMany             func(ctx context.Context, filter repos.Filter) error
	MockDeleteOne              func(ctx context.Context, filter repos.Filter) error
	MockErrAlreadyExists       func(err error) bool
	MockExists                 func(ctx context.Context, filter repos.Filter) (bool, error)
	MockFind                   func(ctx context.Context, query repos.Query) ([]T, error)
	MockFindById               func(ctx context.Context, id repos.ID) (T, error)
	MockFindOne                func(ctx context.Context, filter repos.Filter) (T, error)
	MockFindPaginated          func(ctx context.Context, filter repos.Filter, pagination repos.CursorPagination) (*repos.PaginatedRecord[T], error)
	MockGroupByAndCount        func(ctx context.Context, filter repos.Filter, groupBy string, opts repos.GroupByAndCountOptions) (map[string]int64, error)
	MockIndexFields            func(ctx context.Context, indices []repos.IndexField) error
	MockMergeMatchFilters      func(filter repos.Filter, matchFilters ...map[string]repos.MatchFilter) repos.Filter
	MockNewId                  func() repos.ID
	MockPatch                  func(ctx context.Context, filter repos.Filter, patch repos.Document, opts ...repos.UpdateOpts) (T, error)
	MockPatchById              func(ctx context.Context, id repos.ID, patch repos.Document, opts ...repos.UpdateOpts) (T, error)
	MockPatchOne               func(ctx context.Context, filter repos.Filter, patch repos.Document, opts ...repos.UpdateOpts) (T, error)
	MockUpdateById             func(ctx context.Context, id repos.ID, updatedData T, opts ...repos.UpdateOpts) (T, error)
	MockUpdateMany             func(ctx context.Context, filter repos.Filter, updatedData map[string]any) error
	MockUpdateOne              func(ctx context.Context, filter repos.Filter, updatedData T, opts ...repos.UpdateOpts) (T, error)
	MockUpdateWithVersionCheck func(ctx context.Context, id repos.ID, updatedData T) (T, error)
	MockUpsert                 func(ctx context.Context, filter repos.Filter, data T) (T, error)
}

func NewDbRepo

func NewDbRepo[T repos.Entity]() *DbRepo[T]

func (*DbRepo[T]) Count

func (dMock *DbRepo[T]) Count(ctx context.Context, filter repos.Filter) (int64, error)

func (*DbRepo[T]) Create

func (dMock *DbRepo[T]) Create(ctx context.Context, data T) (T, error)

func (*DbRepo[T]) CreateMany

func (dMock *DbRepo[T]) CreateMany(ctx context.Context, data []T) error

func (*DbRepo[T]) DeleteById

func (dMock *DbRepo[T]) DeleteById(ctx context.Context, id repos.ID) error

func (*DbRepo[T]) DeleteMany

func (dMock *DbRepo[T]) DeleteMany(ctx context.Context, filter repos.Filter) error

func (*DbRepo[T]) DeleteOne

func (dMock *DbRepo[T]) DeleteOne(ctx context.Context, filter repos.Filter) error

func (*DbRepo[T]) ErrAlreadyExists

func (dMock *DbRepo[T]) ErrAlreadyExists(err error) bool

func (*DbRepo[T]) Exists

func (dMock *DbRepo[T]) Exists(ctx context.Context, filter repos.Filter) (bool, error)

func (*DbRepo[T]) Find

func (dMock *DbRepo[T]) Find(ctx context.Context, query repos.Query) ([]T, error)

func (*DbRepo[T]) FindById

func (dMock *DbRepo[T]) FindById(ctx context.Context, id repos.ID) (T, error)

func (*DbRepo[T]) FindOne

func (dMock *DbRepo[T]) FindOne(ctx context.Context, filter repos.Filter) (T, error)

func (*DbRepo[T]) FindPaginated

func (dMock *DbRepo[T]) FindPaginated(ctx context.Context, filter repos.Filter, pagination repos.CursorPagination) (*repos.PaginatedRecord[T], error)

func (*DbRepo[T]) GroupByAndCount

func (dMock *DbRepo[T]) GroupByAndCount(ctx context.Context, filter repos.Filter, groupBy string, opts repos.GroupByAndCountOptions) (map[string]int64, error)

func (*DbRepo[T]) IndexFields

func (dMock *DbRepo[T]) IndexFields(ctx context.Context, indices []repos.IndexField) error

func (*DbRepo[T]) MergeMatchFilters

func (dMock *DbRepo[T]) MergeMatchFilters(filter repos.Filter, matchFilters ...map[string]repos.MatchFilter) repos.Filter

func (*DbRepo[T]) NewId

func (dMock *DbRepo[T]) NewId() repos.ID

func (*DbRepo[T]) Patch

func (dMock *DbRepo[T]) Patch(ctx context.Context, filter repos.Filter, patch repos.Document, opts ...repos.UpdateOpts) (T, error)

func (*DbRepo[T]) PatchById

func (dMock *DbRepo[T]) PatchById(ctx context.Context, id repos.ID, patch repos.Document, opts ...repos.UpdateOpts) (T, error)

func (*DbRepo[T]) PatchOne

func (dMock *DbRepo[T]) PatchOne(ctx context.Context, filter repos.Filter, patch repos.Document, opts ...repos.UpdateOpts) (T, error)

func (*DbRepo[T]) UpdateById

func (dMock *DbRepo[T]) UpdateById(ctx context.Context, id repos.ID, updatedData T, opts ...repos.UpdateOpts) (T, error)

func (*DbRepo[T]) UpdateMany

func (dMock *DbRepo[T]) UpdateMany(ctx context.Context, filter repos.Filter, updatedData map[string]any) error

func (*DbRepo[T]) UpdateOne

func (dMock *DbRepo[T]) UpdateOne(ctx context.Context, filter repos.Filter, updatedData T, opts ...repos.UpdateOpts) (T, error)

func (*DbRepo[T]) UpdateWithVersionCheck

func (dMock *DbRepo[T]) UpdateWithVersionCheck(ctx context.Context, id repos.ID, updatedData T) (T, error)

func (*DbRepo[T]) Upsert

func (dMock *DbRepo[T]) Upsert(ctx context.Context, filter repos.Filter, data T) (T, error)

type DbRepoCallerInfo

type DbRepoCallerInfo struct {
	Args []any
}

Jump to

Keyboard shortcuts

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