Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/reference/enhanced-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
description: Enhancements to the types generated by Prisma
sidebar_position: 4
sidebar_label: Enhanced PrismaClient Types
---

# Enhanced PrismaClient Types

When you call the [`enhance`](./runtime-api#enhance) API, ZenStack not only enhances `PrismaClient`'s runtime behavior, but also alters its types as needed. For example, when you use [polymorphic models](../guides/polymorphism), ZenStack translates the inheritance hierarchy into a proper Prisma schema following the [Multi-table inheritance](https://www.prisma.io/docs/orm/prisma-schema/data-model/table-inheritance#multi-table-inheritance-mti) pattern, however it keeps the typing of the enhanced `PrismaClient` simple and provides a real "polymorphic" DX.

You usually don't need to explicitly refer to the enhanced `PrismaClient` types, but when you need, import it from the `@zenstackhq/runtime/models` module instead of `@prisma/client`.

```ts
import type { Post, Prisma } from '@zenstackhq/runtime/models'
import { getEnhancedPrisma } from '~/db'

const db = getEnhancedPrisma();

// explicitly refer to the enhanced model type
const post: Post = await db.post.findUnique({...});

// explicitly refer to the enhanced input type
const createInput: Prisma.PostCreateInput = { ... };
await db.post.create({ data: createInput });
```
2 changes: 1 addition & 1 deletion docs/reference/error-handling.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Error handling
sidebar_position: 7
sidebar_position: 8
---

# Error Handling
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/plugins/_category_.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
position: 5
position: 6
label: Plugins
collapsible: true
collapsed: true
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/prisma-client-ext.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: APIs ZenStack adds to the PrismaClient
sidebar_position: 4
sidebar_position: 5
sidebar_label: Added PrismaClient APIs
---

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/server-adapters/_category_.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
position: 6
position: 7
label: Server Adapters
collapsible: true
collapsed: true
Expand Down