repository-pattern-nestjs

Define type-safe repository patterns for NestJS services using Prisma.

1|Updated Jan 2, 2025
One-click install
npx skills add https://github.com/allenlin90/eridu-services --skill repository-pattern-nestjs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: repository-pattern-nestjs
Source: https://github.com/allenlin90/eridu-services/tree/main/.agent/skills/repository-pattern-nestjs
Command: npx skills add https://github.com/allenlin90/eridu-services --skill repository-pattern-nestjs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Repositories act as data access abstraction. They should:

  • Encapsulate queries and hide database specifics from services
  • Provide typed interfaces, consistent error handling, and support for soft deletes
  • Enforce a uniform BaseRepository-driven pattern across modules to improve maintainability

Core Features & Use Cases

  • BaseRepository extension for NestJS with Prisma delegates to standardize CRUD paths
  • Specialized find methods, pagination, optimistic locking, and domain-driven queries
  • Guidance for private module repositories and join-table patterns in the monorepo

Quick Start

Create a new repository by extending BaseRepository with your Prisma delegate and wire it into your NestJS module following the architectural guidelines above

Frequently Asked Questions about repository-pattern-nestjs

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

FAQPage Schema
How do I implement a repository pattern in NestJS with Prisma?

To implement a repository pattern in NestJS with Prisma, extend a BaseRepository using your Prisma delegate to encapsulate data access, standardize CRUD paths, and hide database specifics from services.

Why use a BaseRepository for data access in NestJS?

A BaseRepository provides a uniform, type-safe abstraction for data access in NestJS, encapsulating queries, consistent error handling, and soft-delete strategies to improve maintainability across modules.

Can I use soft deletes and optimistic locking with Prisma in NestJS services?

Yes, you can enforce soft deletes and optimistic locking in NestJS services by defining specialized domain-level methods within your Prisma repository extension to manage entity state securely.

Does the repository pattern for NestJS support pagination and custom find methods?

The repository pattern supports pagination and custom find methods by guiding integration with ModelWrapper scaffolding to standardize extensible query patterns for your Prisma entities.

What is the best way to standardize CRUD operations across NestJS modules using Prisma?

The best way to standardize CRUD operations is enforcing a BaseRepository-driven pattern across modules, which prohibits repository-specific HTTP semantics and provides consistent data access paths.