You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to add balance as a computed property of Account
prisma.$extends({result: {account: {balance: {needs: {transactions: true,// <- Type 'boolean' is not assignable to type 'never'.},compute(account){returnsumBy(account.transactions,"amount");},},},},});
Suggested solution
Allow requiring certain relations to be include'd in order to compute a prop.
Alternatives
The alternative I'm currently considering is overwriting query to dynamically add the fields (or maybe a wrapper-class) if the relations are present.
The problem with that approach is that the types won't be correct.
The text was updated successfully, but these errors were encountered:
Hi @defrex!
Thank you for kind words and for opening this request. We plan to eventually implement it (sorry, no ETA yet) and we already have a separate issue for tracking that. I am going to close this as a duplicate. You can follow the progress in #20091
Problem
The new extensions feature is great! My team is already using it for a few things.
However, we'd love to add computed props based on relationships.
Here is a simple example. Given these models
I'd like to add
balance
as a computed property ofAccount
Suggested solution
Allow requiring certain relations to be
include
'd in order to compute a prop.Alternatives
The alternative I'm currently considering is overwriting
query
to dynamically add the fields (or maybe a wrapper-class) if the relations are present.The problem with that approach is that the types won't be correct.
The text was updated successfully, but these errors were encountered: