Skip to content

Commit 61e2cc4

Browse files
authored
doc: update limitation about transaction isolation level (#398)
1 parent 9f5bf83 commit 61e2cc4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/reference/limitations.md

+18
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ This section lists the current limitations of ZenStack.
1313

1414
As a workaround, use [interactive transactions](https://www.prisma.io/docs/concepts/components/prisma-client/transactions#interactive-transactions) instead.
1515

16+
### Minimum transaction isolation level
17+
18+
To ensure access policies are properly enforced, the database's transaction isolation level should be set to at least [Repeatable Read](https://en.wikipedia.org/wiki/Isolation_(database_systems)#Repeatable_reads). This can be done by changing the settings of the database, or providing the `isolationLevel` option when creating `PrismaClient`:
19+
20+
```ts
21+
const prisma = new PrismaClient({
22+
transactionOptions: {
23+
isolationLevel: Prisma.TransactionIsolationLevel.RepeatableRead,
24+
},
25+
});
26+
```
27+
28+
If you don't want to change the global settings, alternatively you can set the `transactionIsolationLevel` option when calling ZenStack's `enhance` API. All the transactions initiated internally by ZenStack will use the specified isolation level.
29+
30+
```ts
31+
const db = enhance(prisma, { user }, { transactionIsolationLevel: 'RepeatableRead' });
32+
```
33+
1634
### MongoDB is not supported
1735

1836
Right now, the focus of this project is SQL databases, and there's no plan to support MongoDB in the near future.

0 commit comments

Comments
 (0)