diff --git a/mongodb.js b/mongodb.js index 193e97bf97088feaa1560c2b0b99a6f3c14c4b9e..783d98c786b2251bf5b77f379d3971ae7ec07e83 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 } }