Search code examples
postgresqlexpressprisma

how to run multiple queries in one call in prisma orm with postgresql


I am using Prisma 4.13 version with PostgreSQL & express for backend.

The back-end code needs to run 3-5 queries in API to get data. I want to run all these queries in one call. This is to save time that goes in call to db, execute queries and return data. Is there a way to run multiple queries in one prisma call?


Solution

  • Yes this can be done, it's basically called relations. So if you make them related you can do it in one call with prisma to the db. You can do a 1 to 1 relationship, 1 to many, and many to many relationships.. this is the true beauty of graphql making your api calls faster.

    (https://www.prisma.io/docs/orm/prisma-schema/data-model/relations)