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

MongoDB and Mongoose - Install and Set Up Mongoose - confused about mlab
0
#1

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?

#2

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

MLab was acquired by MongoDB.

#3

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
#4

Good luck! If you get stuck - ask away.

#5

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?

#6

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)

#7

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!

#8

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

#9

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