Comments (3)
In my case, I was just testing more effective ways to send connection exceptions to a logging service, which in the end I did by just leveraging the $on error event.
I opened the bug anyway because I noticed some official Prisma extensions do override $connect in some cases (e.g. https://github.com/prisma/extension-read-replicas).
from prisma.
Sorry, forgot to markdown
const prisma = new PrismaClient()
const prismaExtension = prisma.$extends({
client: {
async $connect() {
console.warn('Connecting to database')
await prisma.$connect()
}
}
})
prismaExtension.user.findFirst() // Won't log 'Connecting to database'
// prismaExtension.$connect() // Will log 'Connecting to database'
from prisma.
This is generally true for non-extended $connect
too - executing request will establish the connection to the database, but it will not do so by calling the same public $connect
method. What is a usecase for overriding $connect
? Generally, client extensions are meant for additions on top of public client API, not for altering internal behaviours.
from prisma.
Related Issues (20)
- binaries.prisma.sh Returns 404 Not Found Error
- Introduce `connectOrSkip` for optional `connect` operations HOT 2
- Creating and including a related object returns trimmed numbers with `relationJoins`
- `wasm-edge-light-loader.js` importing `node:crypto` instead of using `globalThis.crypto` HOT 11
- Insert or update an item without returning it HOT 3
- Performance problems with batched `findUnique()` HOT 6
- Can't use Prisma Client in Next.js middleware with `@prisma/adapter-pg` and `pg`, even locally HOT 9
- Docs include incorrect information regarding Vercel deployment fix HOT 2
- Add support for `pre`/`post` validation hooks in Prisma schema HOT 3
- Introspecting error with "Microsoft SQL Server 2019" database HOT 1
- Batched `findUnique()` is not chunked and exceeds parameter binding limits HOT 2
- Gin/Gist index operator classes brought in via PostgreSQL extensions
- Accelerate: "Invalid client engine type, please use `library` or `binary`" on Edge HOT 18
- Undefined "meta" when handling "PrismaClientKnownRequestError"
- Queries are getting executed sequentially even when using Interactive transactions API using Promise.all(). HOT 2
- Webstorm does not support prisma 5.15.0 version of preview functionality
- Is the time taken by a complex query in sql run using queryRaw and normal raw sql query the same or does Prisma have to run anything under the hood?
- `update`: Compile-time error is missing if suppliying non-objects to `data` argument
- Add full MongoDB queries to query spans
- findUnique behavior
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prisma.