Skip to content

Commit

Permalink
Fix database reconnection on every request
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek-butola authored and koskimas committed Dec 27, 2021
1 parent 88dd6b1 commit 2ea98ba
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions doc/recipes/multitenancy-using-multiple-databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ If you have a different database for each tenant, a useful pattern is to add a m
```js
const Knex = require('knex');

app.use((req, res, next) => {
const knexCache = new Map();
const knexCache = new Map();

app.use((req, res, next) => {

// Function that parses the tenant id from path, header, query parameter etc.
// and returns an instance of knex. You should cache the knex instances and
// not create a new one for each query. Knex takes care of connection pooling.
Expand Down

0 comments on commit 2ea98ba

Please sign in to comment.