MongoDB and Mongoose - Install and Set Up Mongoose - confused about mlab

This is the url I got so far:
mongodb+srv://admin:@shumongo-chndu.mongodb.net/dbname/test

but I saw others have mlab.com instead of 'mongodb.net`. Am I doing something wrong? Or the instruction is somehow outdated?

hey,
instructions are outdated but donā€™t worry about different url - you can still continue with challenges.

MLab was acquired by MongoDB.

Thanks @orvalho. I had some difficulties to continue with the url I have. But I will keep trying. At least now I know the url is fine.

1 Like

Good luck! If you get stuck - ask away.

Hi @orvalho, I am still a little confused:
Hereā€™s the connection string I got:
mongodb+srv:// admin : <password> @shumongo-chndu.mongodb.net/test?retryWrites=true

Why it points to test? I saw othersā€™ link and they seem to have a user defined names. Do I need to do something more after the mongodb cluster is up and running? For example, create a table inside the instance?

And what is the +srv part? Do i need to remove it?

you need to:

  1. create a new user (username and password will then need to go into that url)
  2. whitelist all IPs

regarding ā€œtestā€ and ā€œ+srvā€ - I have those in all urls of my projects (have not looked into what ā€œtestā€ and ā€œ+srvā€ mean - but thatā€™s not the problem)

Hi @orvalho, I managed to connect to the mongodb. The reason I failed before was that the white-list all ips is not done correctly.

Now I am stuck at the create a model step : ā€œCannot read property ā€˜modelNameā€™ of undefinedā€ .

Not sure what to do to fix the code. Could you please take a look at my project? Thank you very much!

congrats on connecting to Database!

you have written a Schema but have not written a Model.

image

You gonna want to look into Mongoose docs on how to create a Model. Hereā€™s the link:
https://mongoosejs.com/docs/models.html

Hah, tried several things and finally passed this challenge! Thank you @orvalho!
The instruction is kinda vague but now I know the model has to be called ā€œPersonā€.

1 Like