Docs Menu

Docs HomeDevelop ApplicationsMongoDB for VS Code

MongoDB for VS Code Commands

On this page

  • Connection Commands
  • Shell Commands
  • Playground Commands
  • MongoDB for VS Code View Commands

This document lists the VS Code commands available for MongoDB for VS Code. To open the Command Palette and execute these commands:

Operating System
Method
Actions
Any
Visual Studio Code Menu
View > Command Palette
MacOS
Keyboard Shortcut
Press Command + Shift + P
Windows and Linux
Keyboard Shortcut
Press Control + Shift + P

Tip

Enter mongodb in the Command Palette to display all of the MongoDB for VS Code commands you can use.

Run these commands from the Command Palette to create new connections or manage existing connections to your MongoDB deployments.

Configuring a new connection adds a new entry to your Connections list in the MongoDB for VS Code view. Select a connection from the list to activate that connection.

To learn more about connecting to a deployment, see Connect to Your MongoDB Deployment.

Note

You can configure multiple connections, but only have one active connection open at a time.

Command
Description

Connect

Connect to your MongoDB deployment by filling in your connection information in the connection dialog.

Connect to your MongoDB deployment by pasting your connection string URI directly into the command palette. Connecting to a deployment adds a new entry to your Connections list in the MongoDB for VS Code view.

Atlas provides a connection string for your clusters which you can pass into this command.

Disconnect from your active deployment connection.

Select and remove a connection from your list of connections in MongoDB for VS Code.

Note

Removing your current active connection also closes that connection.

Run this command from the Command Palette to open a MongoDB Shell connected to your deployment.

Command
Description

Important

This command is not supported on Windows.

Open the VS Code Terminal and automatically connect a MongoDB shell to the deployment specified in your active connection.

Specify the MongoDB shell to use in the mdb.shell setting. MongoDB for VS Code supports the following shells:

  • Legacy mongo shell

  • mongosh shell.

Important

To launch your selected MongoDB shell, you must:

  • Install the shell you want to use, and

  • Configure your machine's PATH environment variable to include the filepath to your shell binary.

If you install a new version of your MongoDB shell, you will need to update your PATH variable to reference the new version.

Tip

See also:

Run these commands from the Command Palette to create and run playgrounds.

Command
Description

Create a new playground to run against your MongoDB deployment.

By default, playgrounds load with a template containing sample commands. You can disable this template from your extension settings.

Run file you are currently viewing in VS Code as a playground. Your playground runs against the deployment specified in your active connection.

MongoDB for VS Code splits your playground window to display the results in a pane titled Playground Results.json to the right of your playground. If you disabled split-view for your VS Code Editor window, MongoDB for VS Code displays the playground results in a new tab to the right of your playground. If you manually move your playground results, MongoDB for VS Code displays the results in that tab.

Run these commands from the Command Palette to manage the MongoDB for VS Code view in the left navigation panel.

Command
Description
Open and focus on the MongoDB for VS Code view.
If MongoDB for VS Code is hidden from your extension view, show it.
←  ReferenceMongoDB for VS Code Settings →