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
query.ysers.update
block
query: { users: { async update({args, query}) => { // do stuff here } }}
query: { users: { async update({args, query}) => { // do stuff here } }}
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)
new PrismaClient().$extends(userExtension1).$extends(userExtension2)
The issue with this technique is that I will probably end up executing the
query
query
in each extension, leading to unnecessary overload of the database.
Prisma Client extensions are a powerful way to add functionality to your Prisma Client. In this video, we deeply dive into what Prisma Client extensions are and how to build one.