Tell us what’s happening:
I have done everything like it is supposed to (even checked up with the solution), but it keeps failing because the connection times out. I could not find any useful solutions to this, so can anyone help me?
Your code so far
const mongoose = require('mongoose');
mongoose.connect(
process.env.MONGO_URI,
{
useNewUrlParser: true,
useUnifiedTopology: true
}
);
const Schema = mongoose.Schema;
const personSchema = new Schema({
name: {
type: String,
required: true
},
age: Number,
favoriteFoods: [String]
});
var Person = mongoose.model("Person", personSchema);
var createAndSavePerson = function(done) {
var charlesLeclerc = new Person({
name: 'Charles Leclerc',
age: 22,
favoriteFoods: ['Vettel', 'Verstappen']
});
charlesLeclerc.save((err,data) => {
if(err) return done(err);
return done(null,data);
});
};
Your browser information:
User Agent is: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0
.
Challenge: Create and Save a Record of a Model
Link to the challenge: