Connect to Mongodb Atlas Using Mongoose
I’m a big fan of MongoDB. One of these days, I had to deploy a MERN stack app to a shared server. It’s hard to find NoSQL database support in these shared environments.
MongoDB Atlas seems like a good option in such situations.
But there’s a problem. The connect options don’t list mongoose. When you select Node, it shows the MongoDB NodeJS Driver URI.
What about our beloved Mongoose?
We’ll just simply choose version 2.2.12 or later
on the driver and version section.
It’ll show a rather large connection URI, but that’s directly usable in mongoose.
That’s what worked for me.
Precautions
I’d say enable all IPs while testing because then you can ignore the whitelist IP error. Of course, change it once you are able to connect.
Try to pass options as a part of URI and not as a JS object. This one’s a bit weird, but I did it this way.