From cebc490eb3a3077d345351ce3ae001874abca94a Mon Sep 17 00:00:00 2001
From: strokh24 <Rokas.Stankunas@Student.Reutlingen-University.DE>
Date: Mon, 7 Oct 2024 10:16:21 +0200
Subject: [PATCH] Removed creation of collections in mongodb.js

---
 mongodb.js | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/mongodb.js b/mongodb.js
index 193e97b..783d98c 100644
--- a/mongodb.js
+++ b/mongodb.js
@@ -6,19 +6,9 @@ async function connectDB() {
     // Connect using the MongoDB URI from environment variables
     const conn = await mongoose.connect(process.env.MONGO_URI || "mongodb://127.0.0.1:27017/todo_app");
     console.log(`MongoDB connected: ${conn.connection.host}`);
-
-    // Get the database object from the connection
-    const db = conn.connection.db;
-
-    // Check if the collections exist and create them if not
-    await db.createCollection('users');
-    await db.createCollection('todos');
-    await db.createCollection('global');
-
-    console.log('Collections created successfully!');
   } catch (err) {
     console.error(`Error: ${err.message}`);
-    process.exit(1); // Exit the process with failure if the connection or collection creation fails
+    process.exit(1); // Exit the process with failure if the connection fails
   }
 }
 
-- 
GitLab