datastore

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCollection = errors.New("Invalid collection type")
	ErrInvalidPtr        = errors.New("out param is not a valid pointer")
)

Functions

func IsValidPointer

func IsValidPointer(i interface{}) bool

Types

type CollectionKey

type CollectionKey string
const CollectionCtx CollectionKey = "collection"

type DB

type DB interface {
	GetDatabase() *mongo.Database

	FindAll(ctx context.Context, filter bson.M, sort interface{}, projection, results interface{}) error

	UpdateMany(ctx context.Context, filter, payload bson.M, bulk bool) error

	DeleteMany(ctx context.Context, filter bson.M, hardDelete bool) error

	WithTransaction(ctx context.Context, fn func(sessCtx mongo.SessionContext) error) error
}

func New

func New(cfg config.Configuration) (DB, error)

* New initialises a new MongoDB collection pool

type Store

type Store struct {
	// contains filtered or unexported fields
}

func (*Store) DeleteMany

func (d *Store) DeleteMany(ctx context.Context, filter bson.M, hardDelete bool) error

func (*Store) FindAll

func (d *Store) FindAll(ctx context.Context, filter bson.M, sort interface{}, projection, results interface{}) error

func (*Store) GetDatabase

func (d *Store) GetDatabase() *mongo.Database

func (*Store) UpdateMany

func (d *Store) UpdateMany(ctx context.Context, filter, payload bson.M, bulk bool) error

func (*Store) WithTransaction

func (d *Store) WithTransaction(ctx context.Context, fn func(sessCtx mongo.SessionContext) error) error

Jump to

Keyboard shortcuts

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