What problem does it solve?
Inefficient or improperly managed database queries can lead to slow application performance, resource exhaustion, and data inconsistencies, impacting user experience and system stability. This Skill ensures optimal and reliable database interactions.
Core Features & Use Cases
- Repository Pattern: Abstract database access with dedicated repository classes, promoting clean architecture and testability.
- Prisma ORM: Leverage Prisma for type-safe, efficient, and readable database queries, reducing common ORM pitfalls.
- Transaction Management: Ensure data consistency and atomicity by wrapping multiple operations in
prisma.$transaction(), preventing partial updates.
- Soft Delete Pattern: Implement and consistently apply soft delete logic (filtering
deletedAt: null) across all queries, preserving historical data without permanent deletion.
- Use Case: When implementing a
CreateArticleUseCase, ensure that the article creation and any related tag associations are wrapped in a single Prisma transaction to guarantee atomicity, and that all read operations automatically filter soft-deleted articles.
Quick Start
Guide me in creating a new repository method findBySlug for the ArticleRepository that retrieves an article by its slug, ensuring soft-deleted records are excluded and it accepts an optional Prisma transaction client.