-
-
Notifications
You must be signed in to change notification settings - Fork 38
docs: doc changes for release 2.5.0 #361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| --- | ||
| description: Using ZenStack with Prisma Pulse. | ||
| sidebar_position: 14 | ||
| --- | ||
|
|
||
| # Using with Prisma Pulse (Preview) | ||
|
|
||
| ## Introduction | ||
|
|
||
| [Prisma Pulse](https://www.prisma.io/data-platform/pulse) is Prisma's cloud offering that allows you to easily subscribe to real-time data change events from your database. It's a great way to build real-time applications without managing a Change Data Capture (CDC) infrastructure. | ||
|
|
||
| With Prisma Pulse, you can use the new `stream()` API to subscribe to data change events. For example: | ||
|
|
||
| ```ts | ||
| const stream = await prisma.user.stream() | ||
|
|
||
| for await (const event of stream) { | ||
| console.log('just received an event:', event) | ||
| } | ||
| ``` | ||
|
|
||
| The `stream()` API also allows you to filter only the events you're interested in. | ||
|
|
||
| ```ts | ||
| // Filter for new User records with a non-null value for name | ||
| const stream = await prisma.user.stream({ | ||
| create: { | ||
| name: { not: null }, | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| ## ZenStack's access policies and Prisma Pulse | ||
|
|
||
| TLDR: it just works! | ||
|
|
||
| ZenStack's access policies seamlessly work with the `stream()` API without additional configuration. You can simply use an enhanced Prisma client to subscribe to data change events, and the access policies will be enforced automatically. | ||
|
|
||
| ```ts | ||
| const db = enhance(prisma, { user: session.user }); | ||
|
|
||
| // The event stream is automatically filtered by the access policies | ||
| const stream = await db.user.stream(...); | ||
| ``` | ||
|
|
||
| Only events that satisfy the "read" policies will be returned. If there are field-level "read" policies, fields that do not satisfy the policies will be stripped from the event payload. Fields marked with `@omit` are also automatically removed. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1643,10 +1643,10 @@ Attributes `@trim`, `@lower`, and `@upper` are actually "transformation" instead | |
|
|
||
| ### Model-level validation attributes | ||
|
|
||
| You can use the `@@validate` attribute to attach validation rules to a model. | ||
| You can use the `@@validate` attribute to attach validation rules to a model. Use the `message` parameter to provide an optional custom error message, and the `path` parameter to provide an optional path to the field that caused the error. | ||
|
|
||
| ``` | ||
| @@validate(_ value: Boolean, _ message: String?) | ||
| @@validate(_ value: Boolean, _ message: String?, _ path: String[]?) | ||
|
Comment on lines
+1646
to
+1649
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Approve the enhancements to the The updates to the However, there's a minor issue with the Markdown formatting:
Please add a language specification to the fenced code block to resolve the Markdownlint warning. Here's a suggested fix: - ```
+ ```zmodel
@@validate(_ value: Boolean, _ message: String?, _ path: String[]?)ToolsMarkdownlint
|
||
| ``` | ||
|
|
||
| Model-level rules can reference multiple fields, use relation operators (`==`, `!=`, `>`, `>=`, `<`, `<=`) to compare fields, use boolean operators (`&&`, `||`, and `!`) to compose conditions, and can use the following functions to evaluate conditions for fields: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix required: Table format issue.
The table has too many cells as per the Markdownlint warning. Please ensure that the table format is corrected to display all data properly.
Tools
Markdownlint