Hey @igolka97 👋, great question.

While Prisma is unlike traditional ORMs in many ways, it is still possible to wrap it in a thin layer of abstraction if that is something you want for your architecture. Most of the time, wrapping Prisma looks like writing wrapper functions around Prisma queries instead of the usual class-based pattern.

This is a reasonably common question, so here are a few links to previous discussions and questions around this topic:

  • #3929
  • Slack conversation about repository pattern
  • #5273

I would be happy to address any more specific questions you have!

Discussions

Is a repository pattern with generics possible?
Is there a way to use generics for repository patterns using a base repository (example A), or should i do it just like example B, where i have to duplicate all the create, update, e.d. methods? Ex... More on github.com
🌐 github.com
18
14
prisma2 - How can I create a custom repository in Prisma 2 using NestJS like TypeORM? - Stack Overflow
import {EntityRepository, Repository} ... class UserRepository extends Repository { findByName(firstName: string, lastName: string) { return this.findOne({ firstName, lastName }); } } How can I reach the same result using Prisma 2 and NestJS ?... More on stackoverflow.com
🌐 stackoverflow.com
Question about Prisma and DI

Yes, but if you think about changing databases in the future, you have to put another layer of abstraction with repository pattern, in that way, the origin of data can be prisma, firebase, or any other source that you want.

More on reddit.com
🌐 r/node
3
4
January 5, 2022
typescript - Is the Repository Pattern needed with Prisma if you have a service layer? - Stack Overflow
Because Prisma is kind of like an ORM it already gives you great tools for accessing data in the database is a Repository pattern needed.. I have read conflicting opinions and basically it seems to... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Tomray
tomray.dev › nestjs-prisma
Ultimate Guide: How to use Prisma with NestJS - Tom Ray
November 29, 2022 - It's time to finally start working with Prisma in the NestJS app. We're going to use the Repository design pattern - we'll create a layer to encapsulate the logic required to access the database.
🌐
Adarsha Acharya
adarsha.dev › blog › automate-repository-generation-prisma-nestjs
Automating Repository Generation in NestJS with Prisma | Adarsha Acharya
April 4, 2025 - Instead of writing the same CRUD methods for every model, this article will guide you way to dynamically generate repository classes with transaction handling based on the Prisma schema. This approach not only reduces boilerplate code but also ensures consistency across your application. Before starting, make sure you have Nest.js application setup with Prisma. If you haven't done that yet, check out the NestJS + Prisma documentation for a quick setup.
🌐
Synapsestudios
docs.synapsestudios.com › implementation › frameworks › nest › repository-pattern.html
Repository Pattern in NestJS | Synapse Studios Standards
// domain/specifications/active-premium-users.specification.ts export class ActivePremiumUsersSpecification { constructor( private readonly minPurchases: number = 5, private readonly since: Date = subMonths(new Date(), 3), ) {} toQuery() { return { status: 'ACTIVE', subscription_tier: 'PREMIUM', purchases: { count: { gte: this.minPurchases }, }, last_login: { gte: this.since }, }; } } // Repository implementation export class UserRepository { async findBySpecification(spec: Specification): Promise<User[]> { const records = await this.prisma.user.findMany({ where: spec.toQuery(), }); return records.map(this.toDomain); } } // Usage in use case const activeUsers = await this.userRepository.findBySpecification( new ActivePremiumUsersSpecification(10) );
🌐
Medium
medium.com › @jedirichang › nestjs-prisma-transaction-with-repositories-2803e5a5487a
NestJS: Prisma Transaction with Repositories | by Richang Sharma | Medium
September 6, 2024 - Such a situation arose when I was working with NestJS with Prisma as my ORM. I was following the standard architecture of keeping repositories, services, and controllers to execute requests.
Find elsewhere
🌐
Stack Overflow
stackoverflow.com › questions › 66572049 › how-can-i-create-a-custom-repository-in-prisma-2-using-nestjs-like-typeorm
prisma2 - How can I create a custom repository in Prisma 2 using NestJS like TypeORM? - Stack Overflow
import {EntityRepository, Repository} from "typeorm"; import {User} from "../entity/User"; @EntityRepository(User) export class UserRepository extends Repository<User> { findByName(firstName: string, lastName: string) { return this.findOne({ firstName, lastName }); } } How can I reach the same result using Prisma 2 and NestJS ?
🌐
Reddit
reddit.com › r/node › question about prisma and di
r/node on Reddit: Question about Prisma and DI
January 5, 2022 -

I am using prisma for a user data base, and I was following this guide: https://docs.nestjs.com/recipes/prisma

However, I had a question about this code specifically:

@Injectable()
export class UserService {
  constructor(private prisma: PrismaService) {}

  ...

So the UserService takes in a PrismaService object.

But my question is, what if I decide to use some other database in the future, such as Firebase or MongoDB. Won't I have to change the code in UserService because it depends on PrismaService itself? Is there another way to do this?

🌐
JavaScript in Plain English
javascript.plainenglish.io › repository-pattern-set-up-in-node-js-with-prisma-7a39d5867477
Repository Pattern Set Up in Node.Js with Prisma | by Himanshu sagar | JavaScript in Plain English
July 24, 2024 - ... The repository pattern separates data access logic, resulting in a cleaner and more maintainable codebase. Its benefits include improved code organization, data access abstraction, code reusability, enhanced testability, and flexibility.
🌐
Prisma
prisma.io › blog › nestjs-prisma-relational-data-7D056s1kOabc
Handling Relational Data in a REST API with NestJS and Prisma 7
3 weeks ago - Note: The original edition of this series linked to a companion GitHub repository. That repository still targets the older Prisma 4 and NestJS 8 stack, so for the updated series you should continue from your own project.
🌐
LogRocket
blog.logrocket.com › home › exploring the repository pattern with typescript and node
Exploring the repository pattern with TypeScript and Node - LogRocket Blog
June 4, 2024 - That’s how to use the repository. If down the line in the course of the project we decide to switch data access layer to something like Prisma, we’ll just need to create a PrismaPostRepository class that implements the PostRepositoryInterface:
🌐
Stack Overflow
stackoverflow.com › questions › 74832764 › is-the-repository-pattern-needed-with-prisma-if-you-have-a-service-layer
typescript - Is the Repository Pattern needed with Prisma if you have a service layer? - Stack Overflow
So we have to repeatedly write this.prisma.avatarParts.create or just reuse our this.avatarPartsRepo.create. ... Sign up to request clarification or add additional context in comments. ... Yes I find this is true for "mutation" type functionality, the service layer is definately needed to provide your business constraints. But for 99.9% of data "queries" then I havent seen a need. Thoughts? 2023-03-20T05:12:11.847Z+00:00 ... I think repositories are just a way to be ready for some kind of probable changes in your application.
🌐
Medium
medium.com › @Nexumo_ › prisma-or-typeorm-in-2026-the-nestjs-data-layer-call-ae47b5cfdd73
Prisma or TypeORM in 2026? The NestJS Data Layer Call | by Nexumo | Medium
January 21, 2026 - Prisma’s NestJS integration story is also very standardized (PrismaModule/PrismaService patterns are common). TypeORM tends to win when you want ORM ergonomics that feel like classic enterprise patterns: entities, decorators, repositories, cascading relations, and a query builder that can express weird joins without fighting a schema compiler.
🌐
NestJS
docs.nestjs.com › recipes › prisma
Prisma | NestJS - A progressive Node.js framework
Prisma is an open-source ORM for Node.js and TypeScript. It is used as an alternative to writing plain SQL, or using another database access tool such as SQL query builders (like knex.js) or ORMs (like TypeORM and Sequelize).
🌐
DeepWiki
deepwiki.com › nestjs › nest › 8.4-prisma-integration
Prisma Integration | nestjs/nest | DeepWiki
February 16, 2026 - The NestJS repository demonstrates multiple database integration approaches, each suited to different use cases: ... Prisma: Best for greenfield projects prioritizing type safety, modern development experience, and GraphQL integration · TypeORM: Best for existing projects or when Active Record pattern is preferred
🌐
Answer Overflow
answeroverflow.com › m › 1317325835426070648
Prisma using repository pattern
December 14, 2024 - Problems with the Prisma repository pattern? PPrisma / help-and-questions8mo ago · Prisma opening up connections for every repository query · PPrisma / help-and-questions8mo ago · prisma migrate dev hangs using Prisma Postgress · PPrisma / help-and-questions7mo ago ·
🌐
Medium
krsbx.medium.com › repository-pattern-prisma-orm-add91e91de30
Repository Pattern Prisma ORM. Object Relational-Mapping (ORM) is a… | by Muhammad Firdaus Sati | Medium
April 6, 2022 - Not everyone like to use repository pattern some might prefer to use another pattern, but for me I like to use it and here’s how you use repository pattern in Prisma.
🌐
Reddit
reddit.com › r/nestjs › nestjs entity and prisma client
r/nestjs on Reddit: NestJS Entity and Prisma Client
July 22, 2024 -

What is the preferred way to use Entities in the NestJS framework with Prisma?

The command `nest g resource ResourceName`, creates the Controller, Module, Service, and Entity. All the Prisma tutorials and NestJS/Prisma examples show the Service calling directly into the Prisma client. My application is using Prisma to define the tables and run the migrations.

Should I just delete the entities created from the `nest g resource` command?

I don't have a problem with the pattern of going directly to the Prisma Client from the Service, but is this the idiomatic way of doing things in NestJS/Prisma?

Thank you!

For context, I am building a few reference implementations using Prisma, MikroORM, Drizzle, and TypeORM to evaluate which one will work best with my team for a new project.

Update: I decided to skip building entities from the Prisma object returned from Prisma Service. The controller will return a model object and not the entity. Seems like a lot of overhead to convert to an entity, just to convert it to a model. I’m also skipping the Repository pattern. If I ever refactor Prisma to something else, it is the same amount of code to change.

🌐
YouTube
youtube.com › watch
MASTER Next.js with Prisma Repository Pattern - YouTube
🚀 Dive into the world of efficient data management with Prisma Repository Pattern in Next.js! Join us in this tutorial where we explore how to implement the...
Published   March 20, 2024