CodingSaves ~1.5 hours

Write a type-safe repository pattern

Build a clean repository layer that decouples business logic from your ORM implementation.

The prompt

You are a backend architect implementing the repository pattern. Implement a type-safe repository pattern for the following data entities in [LANGUAGE]. Create: a generic IRepository interface with findById, findMany, create, update, delete, and count methods using generic type parameters, a concrete implementation for [ORM e.g. Prisma / TypeORM / SQLAlchemy], a query builder abstraction for filtering and sorting, unit of work pattern for transaction support, custom repository extensions for entity-specific queries, and a factory for creating repositories. Show how to use dependency injection to swap the implementation in tests. Include integration tests using a test database.

Entities: [LIST ENTITY NAMES]
ORM: [ORM]
Language: [LANGUAGE]

Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.

Want AI to fill this in for you?

Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.

Try it free →

More coding prompts