backend_database

Implements repository patterns, transactions, Redis caching, and query optimization for backend databases.

Updated Jan 14, 2026
One-click install
npx skills add https://github.com/jvsandhu/agentic-skills --skill backend-database-jvsandhu
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backend_database
Source: https://github.com/jvsandhu/agentic-skills/tree/main/skills/backend_database
Command: npx skills add https://github.com/jvsandhu/agentic-skills --skill backend-database-jvsandhu

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Backend applications often suffer from N+1 query problems, unsafe money transfers without transactions, and repeated database hits that degrade performance. This Skill provides proven patterns for structuring database access, ensuring data consistency, and optimizing query performance. ## Core Features & Use Cases - Repository Pattern: Abstract database queries behind typed repository interfaces using Prisma, keeping controllers decoupled from data access logic. - Transactions & Caching: Wrap critical operations like money transfers in atomic transactions and cache frequent reads in Redis with TTL expiration. - Query Optimization: Eliminate N+1 problems with include/select clauses and parallelize independent async calls with Promise.all. - Use Case: When building a Node.js API with Prisma, apply these patterns to structure a user repository, cache user lookups in Redis, and run safe balance transfers between accounts. ## Quick Start Apply the backend database skill to refactor my Prisma data access layer with the repository pattern, transactions, and Redis caching.

Frequently Asked Questions about backend_database

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement the repository pattern with Prisma in TypeScript?

Define an interface describing data access methods like findById and create, then implement it in a class that receives PrismaClient via constructor injection. This decouples controllers from ORM specifics and makes the data layer testable.

How to fix N+1 query problems in Prisma?

Replace loops that query related records per item with a single findMany call using the include option to eager-load relations. Use select to fetch only required fields, reducing both query count and payload size.

How do I cache database queries with Redis in Node.js?

Check Redis for a cached key before querying the database, and on a miss store the serialized result with an expiration such as EX 3600. This pattern avoids repeated database hits for frequently read entities like user profiles.

When should I use database transactions in Prisma?

Use prisma.$transaction whenever multiple writes must succeed or fail together, such as transferring money between accounts. Inside the transaction, validate conditions like sufficient balance and throw an error to roll back all changes.

Why are my async database calls slow in Node.js?

Sequential awaits force each query to wait for the previous one. Run independent operations concurrently with Promise.all, and analyze slow queries with EXPLAIN to add missing indexes.