0

I'm a beginner setting up my first full stack project (using Node JS, Express, Mongoose). I'm working out of AWS Cloud9 on an EC2 instance and am connecting to my first MongoDB Atlas cluster. I have successfully linked my AWS and MDB accounts via a VPC.

When setting up a connection to the cluster in MBD, I'm asked to choose a connection method between these two: 1) Connect with the Mongo Shell (Mongo Shell with TLS/SSL support is required) 2) Connect your Application (Get a connection string and view driver connection examples)

What are the pros and cons of each?

The second approach seams straightforward - connect the node app directly to the cluster.

The first is less so - if I'm not locally hosting the files, why would I run the shell? Or would this lead to local hosting? But isn't Atlas a cloud database?

I'm ultimately looking to go the route that in the long term is most scalable and maintainable.

I'm missing something in my understanding here. Any input would be appreciated!!

1 Answers1

1

Since, you have to deploy your application which you have built (using Node JS, Express, Mongoose), you have only one option that is option 2) Connect your Application (Get a connection string and view driver connection examples).

MongoDB Atlas cluster is a MongoDB server. To connect to a server and fetch/add/modify data on it you need some client which will interact with the server.

Mongo shell is an interactive client application. It has an interface with which you can interact with MongoDB.

But the application you have built don't need to interact with shell as an intermediate in-between, it can directly interact with the server using MongoDB Node.js Driver (Mongoose in your case)

Rajat Goel
  • 2,207
  • 17
  • 35