Courses / Node.js
30. Database client instantiation and lifecycle
Initialize a database client (e.g., PostgreSQL or MongoDB driver) and manage its lifecycle.
1 min read Chapter 30 of 48
JavaScript
Database client instantiation and lifecycle
Creating and reusing a single database client connection in your app so queries run reliably and resources are managed.
"I keep opening new DB connections and my app either runs out of connections or is slow."
Instantiate one client, reuse it across requests, and close it on shutdown; avoid creating a new client per request.
"I keep opening new DB connections and my app either runs out of connections or is slow."
Instantiate one client, reuse it across requests, and close it on shutdown; avoid creating a new client per request.