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
Copy file name to clipboardExpand all lines: docs/guides/polymorphism.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -240,6 +240,26 @@ model Video extends Content {
240
240
}
241
241
```
242
242
243
+
### Polymorphic TypeScript Types
244
+
245
+
The TS types generated by Prisma into the `@prisma/client` module have the database representation's typing and do not provide the "polymorphic view". For example, the following code doesn't compile:
246
+
247
+
```ts
248
+
importtype { Prisma } from'@prisma/client';
249
+
250
+
const where:Prisma.PostWhereInput= {};
251
+
console.log(where.published); // error: Property 'published' does not exist on type 'PostWhereInput'
252
+
```
253
+
254
+
To use the TS types with polymorphic view, import the `Prisma` type from the `@zenstackhq/runtime/models` module instead. This module contains types generated by ZenStack that comply with the ZModel schema.
0 commit comments