Share prisma schema and client between two backend services.
I have this backend project where I am creating two services both running on different port e.g httpService , wsService. Though I am challenged with handling prisma between the two services since they are going to rely on the same database, I think they would need to share the prisma client and not to have challenges with manually updating the schema from one service to another. Below is my file structure, whenever I try to run prisma it tries to create a package.json in the root folder which I don't desire. How can I share prisma client between to services running within different docker containers?
I will be glad for any assistance offered. thanks
3 Replies
maybe this might help you; you can run
npx prisma generate
in each subfolder but add this to to both package.json files:
Your folder structure is good, what you need to do is having 2 generators inside you schema.prisma (https://www.prisma.io/docs/orm/prisma-schema/overview/generators) in this way you will be able to specify the
output
of both like this:Generators (Reference) | Prisma Documentation
Generators in your Prisma schema specify what assets are generated when the
prisma generate
command is invoked. This page explains how to configure generators.