Skip to content

Pymongo async implementation#3

Open
hiresh-verma wants to merge 10 commits into
developmentfrom
pymongo-async-implementation
Open

Pymongo async implementation#3
hiresh-verma wants to merge 10 commits into
developmentfrom
pymongo-async-implementation

Conversation

@hiresh-verma

Copy link
Copy Markdown
Owner

No description provided.

- Add AsyncGenericReferenceField for references to any document type
- Add AsyncCachedReferenceField with denormalized field caching
- Add AsyncDeReference for bulk dereferencing to avoid N+1 queries
- Add select_related() to AsyncQuerySet for prefetching references
- Add comprehensive tests for all async reference features (10 tests)
- Add async_run_in_transaction() for MongoDB transactions with commit/rollback
- Add async_switch_db() for switching database aliases
- Add async_switch_collection() for switching collections
- Add transaction commit retry logic for transient failures
- Add comprehensive tests for transactions and context managers (8 tests)
- Tests work with MongoDB Atlas (replica set) or skip gracefully on standalone

Requires MongoDB 4.0+ replica set or sharded cluster for transactions
- Add AsyncIOOperations for all async database operations
- Add async connection management with AsyncMongoClient
- Add async session management using contextvars
- Separate sync and async I/O operations into io/sync and io/aio
- Support PyMongo 4.0+ native async (not Motor)
- Add AsyncDocument with async save(), delete(), reload(), modify()
- Add AsyncQuerySet with async iteration and query methods
- Add AsyncQuerySetManager for managing querysets
- Support async CRUD operations: create, read, update, delete
- Support async aggregation: count(), sum(), average(), distinct()
- Support async query building: filter(), limit(), skip(), order_by()
- Add test_async_document.py for AsyncDocument CRUD operations
- Add test_async_queryset_basic.py for AsyncQuerySet operations
- Add test_async_reference_field.py for AsyncReferenceField functionality
- All tests use pytest-asyncio for async test execution
- Tests cover save, reload, delete, update, queries, and references
- Modify Document base class to support async variants
- Modify QuerySet base class to support async variants
- Extract shared logic to support both sync and async implementations
- Maintain backward compatibility with existing sync API
- Replace MongoDB Atlas connection strings with localhost
- Use localhost:27017 for all async transaction tests
- Ensures tests work with local MongoDB instances
@hiresh-verma
hiresh-verma force-pushed the pymongo-async-implementation branch from 3033f97 to 106fcd9 Compare December 26, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant