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

Tell us what’s happening:

My database was working for the first few challenges but I cannot seem to get past this one.
I am getting an error that I am not authorized on admin to execute command “insert etc”
I have tried with read/write Role, the Admin Role, even adding a specific permision for this database but nothing seems to be working.
Error Message: MongoError: (Unauthorized) not authorized on admin to execute command { insert: “people”, documents: …
ok: 0,
code: 8000,
codeName: ‘AtlasError’

Workspace Snapshot: Dashboard

###Your project link(s)

solution: https://3000-freecodecam-boilerplate-n10dpo1hws5.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

Challenge Information:

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

Where is this error showing up at inside the inspector or the test? I pulled the code from the snapshot but that is only the boilerplate. Anyway local host 3000 is working and I connected to MongoDB.

Yes, MongoDB is connected and working. However I don’t seem to be able to update the database.
The error appears in the terminal that is running node when I run the test from the freeCodeCamp challenge.
On the challenge page it reads: Creating and saving a db item should succeed (Test timed out)

I have figured out the problem.
The connection options: useNewUrlParser: true, useUnifiedTopology: true
needed to be set and I hadn’t done that. Apologies for wasting your time, thank you for the help!

1 Like