MongoDB and Mongoose - Create a Model

Tell us what’s happening:

i have wriiten exact code that was asked but still its showing error

###Your project link(s)

solution: https://3000-freecodecam-boilerplate-ygcg3bvl5fc.ws-us117.gitpod.io

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0

Challenge Information:

MongoDB and Mongoose - Create a Model

here is my entire code

Mod edit: I changed your password. But as said, you should make a new one and not post it.

require('dotenv').config();
// let URI = 'mongodb+srv://user_9:somePassword@cluster0.u6ngq.mongodb.net/db1?retryWrites=true&w=majority&appName=Cluster0'
const mongoose = require('mongoose');
mongoose.connect(MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });

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

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*/);
};

this is as important as a password, you will want to reset the URI to your database

  1. You have commented out the connection string assignment.

  2. You are saving the connection string to a URI variable, but not using it.

  3. MONGO_URI is an undeclared variable. It should be the URI variable or an environment variable, in which case, it would start with process.env

actually ia have already declared the value of MONGO_URI in .env file. that’s why ia have commented out the URI connection string.

As I said, if it is an environment variable, it would be.

process.env.MONGO_URI