We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
database-models
1 parent 6569e17 commit eaac960Copy full SHA for eaac960
‎lib/mongodb.ts‎
@@ -33,6 +33,13 @@ if (!cached) {
33
};
34
}
35
36
+/**
37
+ * Get or establish a cached Mongoose connection to the configured MongoDB URI.
38
+ *
39
+ * Reuses an existing cached connection when available; otherwise establishes a new connection and caches it for subsequent calls.
40
41
+ * @returns The established Mongoose connection
42
+ */
43
async function connectDB() {
44
// If a connection is already cached, use it
45
if (cached.conn) {
@@ -52,4 +59,4 @@ async function connectDB() {
52
59
return cached.conn;
53
60
54
61
55
-export default connectDB;
62
+export default connectDB;
0 commit comments