Strongly Typed JSON
🔋 ZenStack vs Prisma
Strongly typed JSON is a ZModel feature and doesn't exist in Prisma.
ZModel allows you to define custom types and use them to type JSON fields. The ORM respects such fields in two ways:
- The return type of such fields is typed as TypeScript types derived from the ZModel custom type definition.
- When creating or updating such fields, the ORM validates the input against the custom type definition. The engine "loosely" validates the mutation input and doesn't prevent you from including fields not defined in the custom type.
Samples​
zenstack/schema.zmodel
Loading...
- Plain Code
- Interactive Sample
main.ts
Loading...
Click here to pop out if the embed doesn't load an interactive terminal.