Overview
TheRepository class is the heart of FluxCRUD’s data layer. It wraps SQLAlchemy operations into a clean, type-safe API that handles:
- Type Validation: Using Pydantic schemas.
- Caching: Automatic read-through and write-through caching.
- Batching: Optimized database writes.
- N+1 Prevention: Optional DataLoader support (opt-in).
Basic Usage
By default, the Repository uses direct SQL queries for maximum performance.Enabling DataLoader (N+1 Protection)
When resolving relationships in loops (e.g., GraphQL or nested API responses), enable the DataLoader to batch queries automatically.Advanced Features
Caching
WhenCacheManager is provided, get() calls check the cache first.
Batching
Use thebatch_writer context manager for high-performance inserts.
Learn More
- Plugin System - Extend behavior with hooks.
- Unit of Work - Atomic transactions.
- Streaming & Optimization - Handling large datasets.

