What problem does it solve?
Provides a consistent, high-performance repository layer that separates read and write patterns so backend services can run complex, optimized read queries while keeping mutations type-safe and rate-limited.
Core Features & Use Cases
- Raw SQL for Reads: Use parameterized raw SQL queries for all find* methods to maximize performance and control, with column aliasing to convert snake_case to camelCase and nested relation mapping.
- Prisma for Mutations: Perform create, update, and delete operations with Prisma's type-safe API while using a write queue to throttle concurrent writes.
- Cache-aside and Invalidation: Integrate cache lookups for reads, populate caches after DB fallbacks, and invalidate relevant caches after mutations to maintain consistency.
- Relation Loading Patterns: Load one-to-one and one-to-many relations with JOINs or separate queries and merge results using flat-to-nested mapping helpers.
- Use Case: Implement a user repository that returns nested role and social relations via optimized read queries and performs secure, queued updates that clear caches on change.
Quick Start
Use this guide to implement a repository that performs raw SQL reads with camelCase aliasing and nested relation mapping while using Prisma and queueWrite for safe, rate-limited mutations.