Documentation ¶
Index ¶
- type MongoRepository
- func (p MongoRepository[T]) CountDocumentsInCollected(ctx context.Context) (int64, error)
- func (p MongoRepository[T]) Delete(ctx context.Context, id primitive.ObjectID) error
- func (p MongoRepository[T]) DeleteMany(ctx context.Context, ids []primitive.ObjectID) error
- func (p MongoRepository[T]) FindAllPageable(request base_entity.PageableDBRequest, ctx context.Context) (*base_entity.PageableDBResponse[T], error)
- func (p MongoRepository[T]) FindById(ctx context.Context, id primitive.ObjectID) (*T, error)
- func (p MongoRepository[T]) FindByIds(ctx context.Context, ids []primitive.ObjectID) ([]*T, error)
- func (p MongoRepository[T]) FindEntityDocumentByFilter(ctx context.Context, filter bson.M) (*T, error)
- func (p MongoRepository[T]) FindEntityDocumentsByFilter(ctx context.Context, filter bson.M, opts ...*options.FindOptions) ([]*T, error)
- func (p MongoRepository[T]) FindEntityDocumentsByFilterForObject(ctx context.Context, filter bson.M, opts ...*options.FindOptions) ([]T, error)
- func (p MongoRepository[T]) Save(ctx context.Context, entity T) (*T, error)
- func (p MongoRepository[T]) SaveMany(ctx context.Context, entities []interface{}) ([]string, error)
- func (p MongoRepository[T]) Update(ctx context.Context, entity T) (*T, error)
- func (p MongoRepository[T]) UpdateMany(ctx context.Context, entities []T) ([]*T, error)
- type Repository
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]) DeleteMany ¶
DeleteMany delete many existing documents
func (MongoRepository[T]) FindAllPageable ¶
func (p MongoRepository[T]) FindAllPageable(request base_entity.PageableDBRequest, ctx context.Context) (*base_entity.PageableDBResponse[T], error)
func (MongoRepository[T]) FindEntityDocumentByFilter ¶
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
Click to show internal directories.
Click to hide internal directories.