Help creating computed fields
Hi! im trying to do an extension of PrismaClient so I can add a computed field.
each pageItem has a relation of many-to-many with products, and each product have a type.
I wish to generate a computed field named "isMerch" that its true when all the products it contain are of type "MERCH".
Here is my approach, far from being usefull...
The first issue I encounter is on the needs field, how can I use relations?
PD: I restarted to work with prisma after a whole year, i'm a little rusty in a lot of aspects.
2 Replies
The AI helped:
Hey @JuanErnesto 👋
I am glad to hear that the AI response was helpful.
Here's the feature request:
https://github.com/prisma/prisma/issues/20091
And this workaround (which is not completely typesafe)
https://github.com/prisma/prisma/issues/20091#issuecomment-1824063594
GitHub
Support relations in
result
extensions · Issue #20091 · prisma/pr...Problem At the moment, only scalar fields are allowed to be specified in needs block of result extension. This is by design — since we include computed fields into the default selection, we can'...