Put a Schema with mongoose into my replit

Hi, i’m approaching this lesson, so i have to create a Schema, in my replit i wrote into myApp.js this code to add the Schema:

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

const ThePerson = mongoose.model("ThePerson", personSchema);

i’ve written it following this. When i had finisched writting it, i ran the terminal and no errors appears, but when i putted the replit’s link on the lesson page to check the result, i couldn’t pass the test! Hope for a hint!

I think i’ve found the error! in the lesson you told to create a variable (model) called Person from the personSchema, so in my code i edit the variable ThePerson with Person, but there is a fact, in myApp.js there already was a variable Person by default, so i ask you, if i can’t edit the default varaible Person, and i need to call the new model Person too in order to pass the test, how should i do? I tryed to rename the default variable and change it all long in myApp.js but i didn’t succeded, hope for your help!

Solved, here’s my code, it just needed to change the default variable Person in its first presence in the code of myApp.js!


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

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








let Person11;  //<-----this is bad guy 

I tried something very similar as below
Platform: replit

const mongoose = require('mongoose');
require('dotenv').config();

const Schema09 = mongoose.Schema;


var personSchema = new Schema09({
  name: { type: String, required: true },
  age: Number,
  favoriteFoods: [String]
});


const mySecret = process.env['MONGO_URI']
mongoose.connect('mongodb+srv://<username>:<pwd>@freecodecamp.jcajfew.mongodb.net/',  { useNewUrlParser: true, useUnifiedTopology: true });
const Person = mongoose.model('Person', personSchema);


const createAndSavePerson = (done) => {
  done(null /*, data*/);
};

const createManyPeople = (arrayOfPeople, done) => {
  done(null /*, data*/);
};

const findPeopleByName = (personName, done) => {
  done(null /*, data*/);
};

const findOneByFood = (food, done) => {
  done(null /*, data*/);
};

const findPersonById = (personId, done) => {
  done(null /*, data*/);
};

const findEditThenSave = (personId, done) => {
  const foodToAdd = "hamburger";

  done(null /*, data*/);
};

const findAndUpdate = (personName, done) => {
  const ageToSet = 20;

  done(null /*, data*/);
};

const removeById = (personId, done) => {
  done(null /*, data*/);
};

const removeManyPeople = (done) => {
  const nameToRemove = "Mary";

  done(null /*, data*/);
};

const queryChain = (done) => {
  const foodToSearch = "burrito";

  done(null /*, data*/);
};



/** **Well Done !!**
/* You completed these challenges, let's go celebrate !
 */

//----- **DO NOT EDIT BELOW THIS LINE** ----------------------------------

exports.Person = Person;
exports.createAndSavePerson = createAndSavePerson;
exports.findPeopleByName = findPeopleByName;
exports.findOneByFood = findOneByFood;
exports.findPersonById = findPersonById;
exports.findEditThenSave = findEditThenSave;
exports.findAndUpdate = findAndUpdate;
exports.createManyPeople = createManyPeople;
exports.removeById = removeById;
exports.removeManyPeople = removeManyPeople;
exports.queryChain = queryChain;

But I can see the below error

**Creating an instance from a mongoose schema should succeed**
// tests completed
// console output
**[Error: Cannot read properties of undefined (reading 'modelName')]**

Quite not sure where there are going wrong!