Tried all posted suggestions - Still not passing - SOLVED

Hi,

Reading through the forums it seems that most people were able to get a pass by adjusting their dependency versions for mongodb and mongoose. I have tried a dozen different settings and always get the same fail message and console warnings. I have tried using the new functions with the newest versions of mongodb and mongoose installed and cannot get the pass that way either.

My code on Replit:

boilerplate-mongomongoose - Replit

Console feed:

(node:12100) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
Your app is listening on port 3000
OPTIONS
POST
(node:12100) DeprecationWarning: collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead.

Your browser information:

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

Challenge: Delete Many Documents with model.remove()

Link to the challenge:

If I fork your code and use my own DB it passes that test. I would try removing the mongoose dependency and re-add it again.

You can do it from the Terminal tab as well.

npm rm mongoose
npm i -E mongoose@5.4.0
1 Like

Hi,

I just tried replacing my original connect function with:

mongoose.connect(process.env[‘MONGO_URI’], { useNewUrlParser: true });

and now it throws a new error :

MongoError: database name must be a string
at Function.create (/home/runner/boilerplate-mongomongoose/node_modules/mongodb-core/lib/error.js:43:12)

It exits right away after error is thrown.

Hi,

I tried removing and re-installing and it throws the same console messages and fails…

That means your MONGO_URI does not have a database name at the end of it.

It should look something like:

mongodb+srv://YourUserName:YourPassword@cluster0.mongodb.net/YourDataBaseName?retryWrites=true&w=majority

That fixed it! Interesting that I was able to write to the DB using the same URI.

Thanks again Randell!

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