Create a Record in MongoDB

hello there !!
this is my first time of asking here a question, so i hope it came out good. :upside_down_face:
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");
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']});, 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 !!!

Welcome, yudikahn.

You are not supposed to set the MONGO_URI inside your script.

You are supposed to have a seperate file named .env that contains:


Then, you reference that value by calling process.env.MONGO_URI.

Although, re-reading your post, if you managed to save the model, then maybe you did do the above?

A note about using arrow functions: Avoid it

There is a lot more information about this on the Mongoosejs documentation page, but I just avoid using them whenever I work with Mongoose.

Hope this helps

thanks for taking the time to answer !
after a while i noticed FCC already written the functions structure,
I just had to fill them. now its working :smiley:
thanks for the arrow function note!!!