pMullot
Explore posts from serversPPrisma
•Created by pMullot on 9/23/2024 in #help-and-questions
Is "daisy-chaining Extensions" a good practice?
Hi,
I need to execute many dependent processes upon "update" of my "users" table. For that, I understand the best option is to use Prisma Extensions.
However, since each of these processes requires a fair amount of code, I'd like to separate them in different files, in order not to put everything inside the
query.ysers.update
block
The easiest way to proceed would be to extract each process inside its own function, but I'm having a really hard time to declare those functions with type safety, because of the type the args and query variables, as well as the return type.
Another option would be to define several extensions and then daisy chain them like this: new PrismaClient().$extends(userExtension1).$extends(userExtension2)
The issue with this technique is that I will probably end up executing the query
in each extension, leading to unnecessary overload of the database.
What are your recommendations?
NB: I'm following those guidelines to write my extensions: https://www.youtube.com/watch?v=j5LU6q38E-c&t=627s1 replies