Hey I read this <Advanced type safety (Reference)>...
# orm-help
l
Hey I read this Advanced type safety (Reference) but I want to know how to ensure type safety with the JSON field in a model in case I know its type, is there a generic to cast JSON field in my model?
a
Hey Leo 👋, It's not currently possible to type
Json
fields in your Prisma schema, but if you wanted to cast a field after retrieving it through the Prisma client, you could do it using the TypeScript
as
keyword.
Copy code
const typedField = queryResult.jsonField as SomeType
It would be great if you could add your use case or +1 to this issue. This really helps our engineering teams! Let me know if I can help with anything else.
👍 1