MongoDB and Mongoose - Create and Save a Record of a Model

Tell us what’s happening:
Describe your issue in detail here.
Hello can anyone help me , I am stuck here on this problem for a week and I can’t solve it , you can find my code on github

Your project link(s)

solution: GitHub - Yacineos/boilerplate-mongomongoose: A boilerplate for the freeCodeCamp curriculum.

Your browser information:

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

Challenge: MongoDB and Mongoose - Create and Save a Record of a Model

Link to the challenge:

require(‘dotenv’).config();
const mongoose = require(‘mongoose’)
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true })

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

const Person = mongoose.model(‘Person’, personSchema)

const createAndSavePerson = function(done) {
const yacine = new Person({name: ‘Joe’, age: 21, favoriteFoods: [‘pizza’, ‘burger’]});
yacine.save((err, data) => {
if (err) {
done(err);
}
done(null, data);
});
};

and this is the .env file :
MONGO_URI=“mongodb+srv://yacine:<test.123>@cluster0.bnlb0hy.mongodb.net/?retryWrites=true&w=majority”

-----------------------------------------I give up

I can’t pass the tests , even though I created a new user(fcc) for the DB , made sure that the name is correct the password(fcc) correct , the IP adress (0.0.0.0/0) made it from anywhere , and as you told me I added db1 as database name( I made that name up ) and added it after the / and before ? I can’t find the issue !

MONGO_URI=‘mongodb+srv://fcc:fcc@fcc.tf4dpyg.mongodb.net/db1?retryWrites=true&w=majority’

my problem is solved by changing my DNS to 8.8.8.8

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.