MongoDB and Mongoose - Create and Save a Record of a Model

Tell us what’s happening:
----------------------Try so many time but not pass this challenge, all time same error ( Creating and saving a db item should succeed(Time Out) )

const createAndSavePerson = (done) => {
const person = new Person({
name : ‘nik’,
age :24,
favoriteFoods : [‘pizza’]
});
person.save((err,data)=>{
console.log(data)
if(err) {
done(err)
};
done(null, data);
})
};
Describe your issue in detail here.

Your project link(s)

solution: boilerplate-mongomongoose (5) - Node.js Repl - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36

Challenge: MongoDB and Mongoose - Create and Save a Record of a Model

Link to the challenge:

Actually I forked your project and tried by myself, it is passing the test.
Just make sure you added your database url in Replit:
-Click in the padlock icon in the right
-In the “key” field add MONGO_URI
-In the “value” field add your database url.

In this case you may be using MongoCloud, if not create an account and use this online database. It is going to provide you a link to put in your project, just like this one:

mongodb+srv://user:your_password@cluster3.we7abcd.mongodb.net/?retryWrites=true&w=majority

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.