Tell us what’s happening:
I don’t understand what the parameter data
inside function(err, data)
holds. Also have confusion about what done(null, data)
do
Your code so far
var Person = mongoose.model('Person', personSchema);
var createAndSavePerson = function(done) {
var janeFonda = new Person({name: "Jane Fonda", age: 84, favoriteFoods: ["vodka", "air"]});
janeFonda.save(function(err, data) {
if (err) return console.error(err);
done(null, data)
});
};
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36
.
Challenge: Create and Save a Record of a Model
Link to the challenge: