Prisma extension as a Middleware to update a count
In my app, I want to keep track of the numbers of "posts" published by the user.
Instead of computing them on request, I want to keep the value on the database, updating every time the user publish a new post.
To do that, I am using prisma extensions. But:
A- Prisma extensions do not get along with nested operations.
B- If I use nested operations, I get no warning whatsoever, so it's easy to forget that, if I want to get the "middleware" working properly, I cannot use nested ops.
My questions are:
- Is there a way to solve B? Meaning...if I cannot used nested operations, is there a way to make it obvious so it erros when I use them?
- Or is there a completely different approach that is better and I am missing?
Thanks!
0 Replies