diff --git a/repository.go b/repository.go index b043772..ff42588 100644 --- a/repository.go +++ b/repository.go @@ -12,6 +12,8 @@ import ( ) type RepositoryInterface[T Document] interface { + Collection() *mongo.Collection + Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) ([]T, error) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (T, error) FindByID(ctx context.Context, id string, opts ...*options.FindOneOptions) (T, error) @@ -36,6 +38,10 @@ func NewRepository[T Document](collection *mongo.Collection, indexes []mongo.Ind return &Repository[T]{collection: collection, indexes: withTimestampIndexes(indexes)} } +func (s *Repository[T]) Collection() *mongo.Collection { + return s.collection +} + func (s *Repository[T]) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) ([]T, error) { cursor, err := s.collection.Find(ctx, filter, opts...) if err != nil {