Tell us what’s happening:
Describe your issue in detail here.
I tried almost all the variations to create a basic mongoose model. The code that I pasted below was also tested by me in a local Node express application, which worked perfectly fine and a collection was created in Mongoose. But the same code won’t work in replit. Mongoose connects successfully, but the schema is not created. I did not changed server.js file, neither package.json. I also tried updating the packages, but didn’t work.
Your code so far
const mongoose = require(‘mongoose’);
mongoose.connect(process.env.URI, { useNewUrlParser: true, useUnifiedTopology: true }).then(() => console.log(‘Server Running’)).catch((error) => console.log(error))
let Person;
const personSchema = new mongoose.Schema({
name: { type: String, required: true },
age: Number,
favoriteFoods: [String]
});
console.log(“Helolo”)
Person = mongoose.model(“Person”, personSchema);
Your browser information:
Microsoft Edge
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.70
Challenge: MongoDB and Mongoose - Create a Model
Link to the challenge: