Why do we pass the database client in the context
Hey there 👋
In the examples and in T3app we pass the db client in the trpc context
then, to make requests to the db we use it from the context such as
ctx.prisma.whatever.create()
I would like to understand why do we do so.
Why no just import the client and use it such as import { prisma } from "~/server/db";
and then in the router use prisma.whatever.create()
without the ctx.
Why is it used from the context?
What are the benefits?
does it really matter?0 Replies