Skip to content

Conversation

@ChinmayBansal
Copy link
Contributor

Related Issues

Proposed Changes:

Added delete_all_documents() and delete_all_documents_async() methods to MongoDBAtlasDocumentStore to enable deletion of all documents from a collection.

Implementation details:

  • Both sync and async versions implemented following the existing delete_documents() pattern
  • Uses MongoDB's native delete_many({}) command with an empty filter to efficiently delete all documents
  • Follows established patterns from other document stores (Elasticsearch, OpenSearch, Weaviate)
  • Simple implementation without recreate_index parameter (not needed for MongoDB's schema-flexible collections)

Files changed:

How did you test it?

  • Linter: hatch run fmt - All checks passed (15 files unchanged)
  • Type checks: hatch run test:types - No issues found
  • Unit tests: hatch run test:unit - 25 passed
  • Integration tests: Added 4 new integration tests (2 sync + 2 async):
    • test_delete_all_documents: Verifies deletion of multiple documents
    • test_delete_all_documents_empty_collection: Verifies behavior with empty collection
    • test_delete_all_documents_async: Async version with multiple documents
    • test_delete_all_documents_async_empty_collection: Async version with empty collection

Notes for the reviewer

  • The implementation is intentionally simpler than Elasticsearch/OpenSearch/Weaviate versions - MongoDB doesn't require index recreation or batch deletion for this operation
  • Follows the exact same pattern as the existing delete_documents() method in the same file for consistency
  • No error handling wrapper added to match the existing delete_documents() implementation style

Checklist

@ChinmayBansal ChinmayBansal requested a review from a team as a code owner October 18, 2025 18:43
@ChinmayBansal ChinmayBansal requested review from Amnah199 and removed request for a team October 18, 2025 18:43
@github-actions github-actions bot added integration:mongodb-atlas type:documentation Improvements or additions to documentation labels Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:mongodb-atlas type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add delete_all_documents() operation to MongoDBDocumentStore

2 participants