Skip to content

Commit

Permalink
Removes use of interactiveTransactions (redwoodjs#7023)
Browse files Browse the repository at this point in the history
  • Loading branch information
dthyresson authored and jtoar committed Jan 22, 2023
1 parent 5fd5612 commit 66b76bc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 24 deletions.
19 changes: 0 additions & 19 deletions docs/docs/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -635,25 +635,6 @@ You could just write your own function and throw whatever you like, without usin
This validation guarantees that the field(s) given in the first argument are unique in the database before executing the callback given in the last argument. If a record is found with the given fields then an error is thrown and the callback is not invoked.
> **Enable Prisma Preview Feature**
>
> Being able to use transactions with the syntax used internally by `validateUniqueness()` is experimental for Prisma as of v2.29.0. You'll need to enable it as a preview feature. In your `api/db/schema.prisma` file:
>
> ```text {4}
> generator client {
> provider = "prisma-client-js"
> binaryTargets = "native"
> previewFeatures = ["interactiveTransactions"]
> }
> ```
>
> You'll need to regenerate the prisma client and restart your dev server for changes to take effect:
>
> ```bash
> yarn rw prisma generate
> yarn rw dev
>```
The uniqueness guarantee is handled through Prisma's [transaction API](https://www.prisma.io/docs/concepts/components/prisma-client/transactions). Given this example validation:
```jsx
Expand Down
5 changes: 0 additions & 5 deletions packages/api/src/validations/validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,11 +616,6 @@ export const validateWith = (func: () => void) => {
// check that it is only unique among a subset of records with the same
// `companyId`.
//
// As of Prisma v3.2.1 requires preview feature "interactiveTransactions" be
// enabled in schema.prisma:
//
// previewFeatures = ["interactiveTransactions"]
//
// return validateUniqueness('user', { email: 'rob@redwoodjs.com' }, { message: '...'}, (db) => {
// return db.create(data: { email })
// })
Expand Down

0 comments on commit 66b76bc

Please sign in to comment.