Property 'transaction' does not exist on type 'PrismaClient<PrismaClientOptions, never>'
See original GitHub issueBug description
I followed the docs and added previewFeatures = ["transactionApi"] to the generator client block of the schema.prisma file. However I still receive this typescript compiler error that transaction does not exist.
When I try to execute prisma.transaction(...), I get a runtime error:
UnhandledPromiseRejectionWarning: Error: In order to use the .transaction() api, please enable 'experimentalFeatures = "transactionApi" in your schema.
This error seems to contradict what the docs say. So tried to add experimentalFeatures = "transactionApi" to the generator block instead but still have the same error.
How to reproduce
Add this to schema.prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["transactionApi"]
binaryTargets = ["native"]
}
Run npm prisma generate
Observe error when using prisma.transcation
Expected behavior
Expected to not get an error.
Prisma information
prisma/cli@^2.1.1 prisma/client@^2.1.0
Environment & setup
- OS: Mac OS with Docker (Alpine Linux)
- Database: PostgreSQL
- Node.js version: v12.18.2
- Prisma version:
@prisma/cli : 2.2.1
Current platform : darwin
Query Engine : query-engine 832e37683666c748b0a1cbdc2c5068b5e443e816 (at /Users/kevin/MediaHound/client/partners/node_modules/@prisma/cli/query-engine-darwin)
Migration Engine : migration-engine-cli 832e37683666c748b0a1cbdc2c5068b5e443e816 (at /Users/kevin/MediaHound/client/partners/node_modules/@prisma/cli/migration-engine-darwin)
Introspection Engine : introspection-core 832e37683666c748b0a1cbdc2c5068b5e443e816 (at /Users/kevin/MediaHound/client/partners/node_modules/@prisma/cli/introspection-engine-darwin)
Format Binary : prisma-fmt 832e37683666c748b0a1cbdc2c5068b5e443e816 (at /Users/kevin/MediaHound/client/partners/node_modules/@prisma/cli/prisma-fmt-darwin)
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Related StackOverflow Question
The renaming to
experimentalFeatureshappened in 2.3.0 which was release last Tuesday. You should upgrade your CLI and Client to that version, then it should work. (Alternatively you can useexperimentalFeatures = ["transactionApi"]in your schema file with the current version)@pantharshit00 restarting the TS language server fixed it. I appreciate it.