Closed markrieth closed 3 years ago
Thanks a lot for raising this issue. This is definitely something we've thought about before (e.g. here https://github.com/prisma/specs/issues/444).
I'm also looking for this feature. I need to process the data on the backend side in some sort of queue, where I'd like to watch for status changes of entities and perform some operations.
I could technically do it just after I perform updates, but the goal of my architecture is to make processing fully independent from CRUD implementation
Any Progress? It's Important.
@chareice I think you can use a Prisma middleware for this now: https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/middleware
This is covered by middlewares. If your use-case might not be supported, please create a separate issue.
Problem
Prisma Client lacks observable lifecycle events or database triggers. Popular alternatives to prisma (and even databases themselves) have these as mature and well documented features. For example, Hasura and Sequelize. Having triggers / events is important because it opens up huge possibilities with the prisma-nexus plugin. The goal would be to leverage the code reduction and API consistency that nexus allows without having to tap into a custom mutation for seemingly every case but the most absolutely simplified. Not to mention data validation.
Solution
Prisma Client should have a way to define functions before and after crud operations. Here is an example that I thought of which would be pretty common. The Sequelize link I posted above also has plenty of examples and concepts, basically an instruction guide on what to include.
Alternatives
Additional context