Mongodb Visual Studio Code



NOTE: This extension is DEPRECATED. Please use the Cosmos DB extension which supports connecting to local and remote MongoDB databases.

The MongoDB extension makes it easy to work with MongoDB NoSQL databases, collections, and documents. With this extension, you can:

  • Connect to local or hosted (e.g. Azure CosmosDB) servers
  • Create and view MongoDB databases and collections with the MongoDB Explorer
  • Author MongoDB 'Scrapbooks' with rich IntelliSense (completions) for MongoDB scripts, including collections
  • Execute scripts and see results directly in VS Code
  • Update documents in place
  • Install Mongo DB and Mongo shell.

Mongo Explorer

  • Add a server by clicking the + button in the title.
    • Typical connection string for a local MongoDB instance: mongodb://localhost:27017
  • Expand the connected server to see the Databases
  • Click on a collection to see the documents
  • Remove a server by right clicking on the server name and selecting the Remove Server command

Mongo 'Scrapbooks'

  • Configure the user setting mongo.shell.path to your mongo shell executable path
  • Click on any DB to open the Mongo shell playground editor
  • Enter your scripts, eg: db.<collectionName>.find()
  • IntelliSense (completions) will be provided as you write your scripts
  • Select the script and press CMD+' (CTRL+' on Windows and Linux) to see the results
  • Edit your documents, right click, and choose the Update command to persist changes to the database

There are a couple of ways you can contribute to this repo:

  • Ideas, feature requests and bugs: We are open to all ideas and we want to get rid of bugs! Use the Issues section to either report a new issue, provide your ideas or contribute to existing threads.
  • Documentation: Found a typo or strangely worded sentences? Submit a PR!
  • Code: Contribute bug fixes, features or design changes:
    • Clone the repository locally and open in VS Code.
    • Open the terminal (press CTRL+`) and run npm install.
    • To build, press F1 and type in Tasks: Run Build Task.
    • Debug: press F5 to start debugging the extension.

Legal

Before we can accept your pull request you will need to sign a Contribution License Agreement. All you need to do is to submit a pull request, then the PR will get appropriately labelled (e.g. cla-required, cla-norequired, cla-signed, cla-already-signed). If you already signed the agreement we will continue with reviewing the PR, otherwise system will tell you how you can sign the CLA. Once you sign the CLA all future PR's will be labeled as cla-signed.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

License

Transcript from the 'Working with MongoDB' Lesson

StudioAzure data studio mongodb
  1. The 'Working with MongoDB' Lesson is part of the full, Visual Studio Code Can Do That? Course featured in this preview video. Here's what you'd learn in this lesson: Burke demonstrates how to create, connect and update a MongoDB database using VS Code.
  2. The 'Working with MongoDB' Lesson is part of the full, Visual Studio Code Can Do That? Course featured in this preview video. Here's what you'd learn in this lesson: Burke demonstrates how to create, connect and update a MongoDB database using VS Code.
  3. Mongodb visual-studio-code amazon-ec2. Visual-studio-code: how to run extension locally on my laptop when connected to another machine with Remote-SSH.

[00:00:00]
>> Burke Holland: The other way to work with MongoDB is with something called MongoDB Scrapbooks. This is part of the Cosmos DB extension. So I'm gonna Cmd+Shift+P and then I'm just gonna look for scrapbook, and choose New Mongo Scrapbook. And now I'm connected to lamp. If I type DB and hit a dot it gives me and prompts me with all the things that I can do from here with the MongoDB API.

You can execute the javascript code via mongo shell in Visual Studio code. Write all of your javascript code that connects with mongodb and defines all your function and save it as mongoScript.js.

Mongodb C# Visual Studio Code

[00:00:33] It sees that I have a colors collection so it puts that at the top collections are at the top. So I'm gonna choose colors, and then we can run a find command. If you're not familiar with MongoDB, it's okay. It's just a different API for getting data out of the database.

Conectar Mongodb Con Visual Studio Code

[00:00:48] So I'm gonna hit dot, and then we can do find. See, these are all the different things we can do on this instance. I'm gonna say find and then like this, this is all you have to do to retrieve records for MongoDB. Then we wanna execute this. So we can do execute here like this.

[00:01:06] And then here's all of our records on this side. The other option is to do Command Shift and then the double quotes button. And that is the keyboard shortcut for the same thing. Now, if we come to this side over here and we change this, and click Save, what happens?

Azure Data Studio Mongodb

[00:01:24] We've changed again directly from the editor. So you can see here that you can query and alter your data directly from VS Code. You don't need to drop down into the Mongo shell to do that, and you don't need another tool to do it either. Now in this same container where I've given you MongoDB, I've also given you something called SQL Lite.

Vs Code Mongodb

[00:01:50] If you're not familiar with SQL light, it is a file based database that supports SQL. And it's frequently used in mobile applications. So a lot of the mobile apps that you have on iOS and Android use SQL light. It's a very, very good alternative. If you want to have a lightweight file based database.