Connecting M121 Atlas To Visual Studio Code

There is a MongoDB extension for visual studio code that allows for a connection to the database. When looking at the extension, it asks for the connection string… When I copy in the string in the setup video it will not connect.

Is there a way to link the atlas database for this course with visual studio code? That way I can have an editor and I can use Visual Studio to write and execute my aggregation pipelines.

If you can provide the hostname and replset name, the MongoDB extension for Visual studio code can connect using LDAP of m121 for user name and aggregation as the password. Can you provide the hostname and replset name?

1 Like

Post a screenshot of the error you are having that shows the connection string you are using.

I got it to connect to VS Code… This give you the ability to run the aggregations directly from your editor… Do you know about this? If not, I can post the procedure to connect.

1 Like

Hey @David_44057,

I am glad you were able to figure out the solution :clap:

It would be great if you can share your findings and procedure to connect, as it would be helpful for our community members.

Please feel free to reach out if you have any additional questions.

Kind Regards,
Sonali Mamgain

Ok… I will go through how to do this and provide screenshots

First… Download VS code to your computer. It doesn’t matter if you use iOS or Intel… It will work on both systems.

Once VS Code is downloaded launch the application and in the left side, the 5th icon from the top is extensions. Select this and in the search bar on the top type MongoDB.

The MongoDB plugin will come up…

Install the plugin and a leaf should appear below the lefthand extension icon.

Select the leaf and it will bing up the MongoDB plugin. Select the Add Connection Tab

Select the Open form under the Advanced Connection Settings.

This will bring up a form. There should be one host field, the Replica set name field, and at the bottom there is connection methods… Configure the form like the pic below. Add two hosts and select user/password authentication method.

From this connection string…

mongo "mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/aggregations?replicaSet=Cluster0-shard-0" --authenticationDatabase admin --ssl -u m121 -p aggregations --norc

cluster0-shard-00-00-jxeqq.mongodb.net” is host 1
cluster0-shard-00-01-jxeqq.mongodb.net” is host 2
cluster0-shard-00-02-jxeqq.mongodb.net” is host 3

“Cluster0-shard-0” is the Repl Set Name

User is m121
Pwd is aggregations

This should connect to the database and allow you to run the aggregations from VS Code.

There is a playground feature that is really neat… you can write out your queries and run them right from the IDE. (You will have to read on VS site about the use of Playground)

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.