repository

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoRepository

type MongoRepository[T base_entity.Entity] struct {
	Collection *mongo.Collection
}

MongoRepository Default implementation of the base repository interface You can always supply a custom implementation to suite your needs

func (MongoRepository[T]) CountDocumentsInCollected

func (p MongoRepository[T]) CountDocumentsInCollected(ctx context.Context) (int64, error)

func (MongoRepository[T]) Delete

func (p MongoRepository[T]) Delete(ctx context.Context, id primitive.ObjectID) error

Delete an existing document

func (MongoRepository[T]) DeleteMany

func (p MongoRepository[T]) DeleteMany(ctx context.Context, ids []primitive.ObjectID) error

DeleteMany delete many existing documents

func (MongoRepository[T]) FindAllPageable

func (MongoRepository[T]) FindById

func (p MongoRepository[T]) FindById(ctx context.Context, id primitive.ObjectID) (*T, error)

FindById find by _id

func (MongoRepository[T]) FindByIds

func (p MongoRepository[T]) FindByIds(ctx context.Context, ids []primitive.ObjectID) ([]*T, error)

FindByIds find a list of documents by ids

func (MongoRepository[T]) FindEntityDocumentByFilter

func (p MongoRepository[T]) FindEntityDocumentByFilter(ctx context.Context, filter bson.M) (*T, error)

func (MongoRepository[T]) FindEntityDocumentsByFilter

func (p MongoRepository[T]) FindEntityDocumentsByFilter(ctx context.Context, filter bson.M, opts ...*options.FindOptions) ([]*T, error)

FindEntityDocumentsByFilter find a list of documents by filter

func (MongoRepository[T]) FindEntityDocumentsByFilterForObject

func (p MongoRepository[T]) FindEntityDocumentsByFilterForObject(ctx context.Context, filter bson.M, opts ...*options.FindOptions) ([]T, error)

FindEntityDocumentsByFilterForObject find 1 document by filter

func (MongoRepository[T]) Save

func (p MongoRepository[T]) Save(ctx context.Context, entity T) (*T, error)

Save create a new document

func (MongoRepository[T]) SaveMany

func (p MongoRepository[T]) SaveMany(ctx context.Context, entities []interface{}) ([]string, error)

SaveMany create many documents

func (MongoRepository[T]) Update

func (p MongoRepository[T]) Update(ctx context.Context, entity T) (*T, error)

Update an existing document

func (MongoRepository[T]) UpdateMany

func (p MongoRepository[T]) UpdateMany(ctx context.Context, entities []T) ([]*T, error)

UpdateMany many existing documents

type Repository

type Repository[T base_entity.Entity] interface {
	Save(ctx context.Context, entity T) (*T, error)
	SaveMany(ctx context.Context, entities []interface{}) ([]string, error)
	Update(ctx context.Context, entity T) (*T, error)
	UpdateMany(ctx context.Context, entities []T) ([]*T, error)
	FindById(ctx context.Context, id primitive.ObjectID) (*T, error)
	Delete(ctx context.Context, id primitive.ObjectID) error
	DeleteMany(ctx context.Context, ids []primitive.ObjectID) error
	FindByIds(ctx context.Context, ids []primitive.ObjectID) ([]*T, error)
	FindEntityDocumentsByFilter(ctx context.Context, filter bson.M, opts ...*options.FindOptions) ([]*T, error)
	FindEntityDocumentByFilter(ctx context.Context, filter bson.M) (*T, error)
	CountDocumentsInCollected(ctx context.Context) (int64, error)
	FindAllPageable(request base_entity.PageableDBRequest, ctx context.Context) (*base_entity.PageableDBResponse[T], error)
}

Repository base repository interface

Jump to

Keyboard shortcuts

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