Create and Save a Record of a Model // MongoDB

Tell us what’s happening:
Trying to complete this challenge, I get the error:
MongoError: (Unauthorized) not authorized on admin to execute command
I have whitelisted the 0.0.0.0 ip and allowed admin access to my user. The password is correct. I’ve copypasted the code solution from “Get a hint” but it’s not working. I’ve copypasted the url to the database.

Your project link(s)

solution: boilerplate-mongomongoose - Replit

Your browser information:

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

Challenge: Create and Save a Record of a Model

Link to the challenge:

what connection string are you using ? have you given database name Cluster0 to the string

1 Like

I copied the connection string directly from the mongoDB button, the string looks like this:

mongodb+srv://test:<password>@cluster0.oouas.mongodb.net/?retryWrites=true&w=majority

(I’ve replaced <password> with my password)

 mongodb+srv://test:<password>@cluster0.oouas.mongodb.net/Cluster0?retryWrites=true&w=majority

I have added Cluster0 to the string try it

1 Like

Wow, thank you! Why wouldn’t they provide that in the string to copy paste :frowning:

:smiley: you might have heard about books Learn javascript hard way :rofl:, I learned it hardway spending days to know that the connection string needs a database name, even people don’t know what the name of database is, to be honest backend challenges have too many issues, when I was doing timestamp project it never passed on my pc after hours of searching I found that trying on mobile phone will make it pass and that was it but unfortunately I ignored this knowledge first to wander for hours anyway cheers! you got it :innocent:

1 Like

The challenge was accepted, but when I go and check the database, it says I have the collection Cluster0.people, but there’s nothing inside it.