PLEASE HELP Error on Create Many Records with model.create() Challenge

Hello D Letulle,

The link is https://replit.com/@codingr0/boilerplate-mongomongoose for the replit.com repo. Thank you in advance,

@mientje
Thank you. I updated the code to include the error block of code in the mongodb connection function.

@mientje @jsdisco @dLetulle
The forum states I have reached the max replies for today, so I cannot reply to posts. Thank you all for your advice.

Hi,

You have to connect with this code:

mongoose.connect(process.env.MONG0_URI,  {useNewUrlParser: true, useUnifiedTopology: true, useFindAndModify: false }, (err, res)=>{
  if(err){
    console.error(err + "error" + err )
  }else{
    console.log("successful database connection");
  }
});

You have not used this connection string, only part of it, can you try that? ( you can find it in the first challenge : install and set up mongoose.) The callback is optional, I don’t remember where I found that code, it might show you what’s going on.

1 Like

Ok, Will read your reply tomorrow.

Take care,
Karin

Apologies for writing myself and all those other people into your database, I’m currently learning about internet security and you had offered sensitive details about your connection, so I gave it a shot. Your connection string is this:

MONGO_URI = mongodb+srv://<yourUserName>:<yourPassword>@cluster0.y97qq.mongodb.net/<yourDBname>

Insert <yourUserName>, <yourPassword> and <yourDBname>.

Your create() function is fine, you only had the wrong connection string.

Also, never share the content of your .env file unless you’re in a learning environment like FCC (plus, never use that database again for real projects).

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