mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
cache mongo client - not sure if it makes a diff 🤷
This commit is contained in:
committed by
Thomas Ruoff
parent
451f03549d
commit
f1ff6b0a41
@@ -6,11 +6,14 @@ import { MongoDBAdapter } from "@next-auth/mongodb-adapter"
|
|||||||
import { MONGO_URI, MONGODB_OPTIONS } from "../../../db"
|
import { MONGO_URI, MONGODB_OPTIONS } from "../../../db"
|
||||||
import { MongoClient } from "mongodb";
|
import { MongoClient } from "mongodb";
|
||||||
|
|
||||||
let mongooseConnection: Mongoose;
|
let client: MongoClient;
|
||||||
|
|
||||||
async function getMongoClient() {
|
async function getMongoClient() {
|
||||||
const client = new MongoClient(MONGO_URI, MONGODB_OPTIONS);
|
if (!client) {
|
||||||
await client.connect();
|
client = new MongoClient(MONGO_URI, MONGODB_OPTIONS);
|
||||||
|
await client.connect();
|
||||||
|
}
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user