[PRISMA] Adding method with param in result object
Hi, I have seen the documentation about adding method to the result object. I would like to add a method with parameter, NOT static method in result object. Is that possible?
https://www.prisma.io/docs/concepts/components/prisma-client/client-extensions/result#add-a-custom-method-to-the-result-object
3 Replies
Does this method interact with the dB at all?
I'm hesitant to say this is a good pattern tbh. My brain would just make a generateDiscount util function that takes a user and a discountPercent
No. It will interact with some of the result value.
That's one solution for sure. But it's a big app, so a method would help maintaining and keep track of it.
Idk my fp lovers will disagree. If you want it though what's not working about the approach linked on the docs above?
Does it not allow a second argument or somthing?
The other option would be to create a method that take a user and mounts the fucntion, so in effect your query result really is a dto
like