Connecting to MongoDB

using the line in the video (MongoDB Connection)

const client = await MongoClient.connect(MONGO_URL)

was throwing a deprecation warning so I looked up the useNewUrlParser way to do things

and i found this

const client = await MongoClient.connect(“mongodb://localhost:27017/tododb”, { useNewUrlParser: true })

this worked and the warning disappeared.

What seems to be working too:

const client = await MongoClient.connect(MONGO_URL + “/” + DB_NAME, { useNewUrlParser: true})

I tried to combine the MONGO_URL and DB_NAME inside the connect method while passing the URL argument and it seems to be working fine but I was wondering if it could cause problems in situations I haven’t seen yet.

No, it won’t cause any problem.