mongo

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Attr

type Attr struct {
	Name       string
	Value      any
	Comparison criteria.Comparator
}

func (Attr) GetExpression

func (a Attr) GetExpression() bson.M

type Criteria

type Criteria interface {
	GetExpression() bson.M
}

func ConvertToMongoCriteria

func ConvertToMongoCriteria(c criteria.Criteria, subject entity.Entity) (Criteria, error)

type MongoAnd

type MongoAnd struct {
	Operands []Criteria
}

func (MongoAnd) GetExpression

func (a MongoAnd) GetExpression() bson.M

type MongoNot

type MongoNot struct {
	Operand Criteria
}

func (MongoNot) GetExpression

func (n MongoNot) GetExpression() bson.M

type MongoOr

type MongoOr struct {
	Operands []Criteria
}

func (MongoOr) GetExpression

func (o MongoOr) GetExpression() bson.M

type Repository

type Repository[K entity.Entity] struct {
	Collection *mongo.Collection
	// contains filtered or unexported fields
}

func NewMongoRepository

func NewMongoRepository[K entity.Entity](collection *mongo.Collection) *Repository[K]

func NewMongoRepositoryWithOpts

func NewMongoRepositoryWithOpts[K entity.Entity](collection *mongo.Collection, logger *logrus.Entry) *Repository[K]

func (*Repository[K]) Create

func (r *Repository[K]) Create(ctx context.Context, e K) (K, error)

func (*Repository[K]) Delete

func (r *Repository[K]) Delete(ctx context.Context, entity K) error

func (*Repository[K]) Match

func (r *Repository[K]) Match(ctx context.Context, c criteria.Criteria) ([]K, error)

func (*Repository[K]) MatchOne

func (r *Repository[K]) MatchOne(ctx context.Context, c criteria.Criteria) (k K, err error)

func (*Repository[K]) Read

func (r *Repository[K]) Read(ctx context.Context, id entity.Id) (e K, err error)

func (*Repository[K]) ReadAll

func (r *Repository[K]) ReadAll(ctx context.Context) ([]K, error)

func (*Repository[K]) Start

func (r *Repository[K]) Start(ctx context.Context, onBootstrap func(ctx context.Context) error) error

func (*Repository[K]) Update

func (r *Repository[K]) Update(ctx context.Context, entity K) error

Jump to

Keyboard shortcuts

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