Create and Save a Record of a Model challenge is not updating in the database

I’ve succeded in passing this challenge but I’m not getting any document/record in my database. Besides this I’m also getting a message saying useUnifiedTopology is not supported (Im working on Replit).

mongoose.connect(process.env['MONGO_URI'], {
        dbName: process.env.DB_NAME,
        useNewUrlParser: true,
        useUnifiedTopology: true,
        useFindAndModify: false,
        useCreateIndex: true,
        console.log('database connected.')
    }).catch((err) => console.log(err.message))

var personSchema = new mongoose.Schema({
  name: {type: String, required: true},
  age: Number,
  favoriteFoods: [String]

var Person = mongoose.model('Person', personSchema);

var createAndSavePerson = (done) => {
  var janeFonda = new Person({name: "Jane Fonda", age: 84, favoriteFoods: ["eggs", "fish", "fresh fruit"]});, data) {
    if (err) return console.error(err);
    done(null, data);

I literally copied the solutions to the challenges in order to see if i did something wrong. I’ve also checked the way I declared the URI but doesn’t seem to be the problem.

On mongoDB I can see that the storage size changes but no the documents.

Please post the so we can see all the files in the project.


The reason you do not see a record is the record gets deleted right after the JSON response is pushed back to the browser. See this line in the server.js file that removes the record

Why is it there? We’re not supposed to see a result for this challenge?

I modified the server.js and erased that line but nothing changed.

It is there to bring the empty database back to empty before running other tests. Extra data in the database when certain tests run could produce a false negative result.

When I remove the line and restart the server and submit the project url, the record remains in the database. I just looked at your project code and it still shows the line I highlighted there which would explain why it does not remove the record created.

I checked again removed it and loaded the page again, still nothing.

Is it the same link you posted above?

Yes, i removed line 104

Not sure why when I look at your project link above, I still see line 104.

I don’t understand why that happens.

I am not sure what to tell you at this point. If you Stop the server and restart it after deleting that line, I would think I would see the change when viewing the files. That is kind of the whole point of

The file I am looking at is: