hello there !!
this is my first time of asking here a question, so i hope it came out good.
i am stuck in the " Create and Save a Record of a Model" challenge in the mongoDB challenges.
my code looks like that:
const mongoDB = require("mongodb");
const mongoose = require("mongoose");
process.env.MONGO_URI="mongodb+srv://yudikahn:<myPasswordHere>@fcc-myfirstcluster-fecus.mongodb.net/test?retryWrites=true&w=majority";
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });
var PersonSchem = new mongoose.Schema({
name : {type:String, required: true},
age : Number,
favoriteFoods: [String]
});
var Person = mongoose.model('Person', PersonSchem);
var createAndSave = (done) => {
var person1 = new Person({name:'dan', age:22, favoriteFoods:['a','b','c']});
person1.save((err, data)=>err?done(err):done(null, data));
};
and i dont know what’s wrong with it…
I also checked the database, and the data/object was saved successfully…
thanks !!!