MongoDB for VS Code Commands命令

On this page本页内容

Note
Preview预览

MongoDB for VS Code is currently available as a Preview in the Visual Studio Marketplace.MongoDB for VS Code目前在Visual Studio Marketplace中作为预览版提供。The product, its features, and the corresponding documentation may change during the Preview stage.在预览阶段,产品、其功能和相应的文档可能会更改。

This document lists the VS Code commands available for MongoDB for VS Code.本文档列出了MongoDB for VS Code可用的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.在命令面板中输入MongoDB以显示您可以使用的所有MongoDB for VS Code命令。

Run these commands from the Command Palette to create new connections or manage existing connections to your MongoDB deployments.从命令面板运行这些命令,以创建新的连接或管理到MongoDB部署的现有连接。

Configuring a new connection adds a new entry to your Connections list in the MongoDB for VS Code view.配置新连接将在MongoDB for VS Code视图中的连接列表中添加一个新条目。Select a connection from the list to activate that connection.从列表中选择一个连接以激活该连接。

To learn more about connecting to a deployment, see Connect to Your MongoDB Deployment.要了解有关连接到部署的更多信息,请参阅连接到MongoDB部署

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.通过在连接对话框中填写连接信息来连接到您的MongoDB部署。

Connect with Connection String

Connect to your MongoDB deployment by pasting your connection string URI directly into the command palette.通过将连接字符串URI直接粘贴到命令面板中,连接到MongoDB部署。Connecting to a deployment adds a new entry to your Connections list in the MongoDB for VS Code view.连接到部署在MongoDB forVS Code视图中的连接列表中添加一个新条目。

Atlas provides a connection string for your clusters which you can pass into this command.Atlas为您的集群提供了一个连接字符串,您可以将它传递给这个命令。

Disconnect

Disconnect from your active deployment connection.断开与活动部署连接的连接。

Remove Connection

Select and remove a connection from your list of connections in MongoDB for VS Code.在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.从命令面板运行此命令,打开连接到部署的MongoDB Shell。

Command命令 Description描述

Launch MongoDB Shell

Important

This command is not supported on Windows.Windows不支持此命令。

Open the VS Code Terminal and automatically connect a MongoDB shell to the deployment specified in your active connection.打开VS Code“终端”并自动将MongoDB shell连接到活动连接中指定的部署。

Specify the MongoDB shell to use in the mdb.shell setting.指定要在中使用的MongoDB shellmdb.shell设置MongoDB for VS Code supports the following shells:MongoDB for VS Code支持以下shell:

  • Legacy mongo shell旧版mongo shell
  • mongosh shell. shell。
Important

To launch your selected MongoDB shell, you must:要启动选定的MongoDB shell,必须:

  • Install the shell you want to use, and安装要使用的外壳,然后
  • Configure your machine's PATH environment variable to include the filepath to your shell binary.配置您的计算机的PATH环境变量,以包括shell二进制文件的filepath。

If you install a new version of your MongoDB shell, you will need to update your PATH variable to reference the new version.如果安装新版本的MongoDB shell,则需要更新PATH变量以引用新版本。

Tip
See Also:另请参见:

Run these commands from the Command Palette to create and run playgrounds.从命令选项板运行这些命令来创建和运行演练场

Command命令 Description说明

Create MongoDB Playground

Create a new playground to run against your MongoDB deployment.创建一个新的游乐场来运行您的MongoDB部署。

By default, playgrounds load with a template containing sample commands.默认情况下,操场使用包含示例命令的模板加载。You can disable this template from your extension settings.您可以从扩展设置中禁用此模板。

Run All From Playground

Run file you are currently viewing in VS Code as a playground.将当前在VS Code中查看的文件作为演练场运行。Your playground runs against the deployment specified in your active connection.您的演练场与活动连接中指定的展开相对应。

MongoDB for VS Code outputs the results of your playground in the Output view in VS Code.MongoDB for VS Code在VS Code的“输出”视图中输出演练场的结果。

Run these commands from the Command Palette to manage the MongoDB for VS Code view in the left navigation panel.从命令面板运行这些命令,以管理左侧导航面板中的MongoDB for VS Code视图。

Command命令 Description描述

Focus on MongoDB View

Open and focus on the MongoDB for VS Code view.打开并关注MongoDB for VS Code视图。

Show MongoDB

If MongoDB for VS Code is hidden from your extension view, show it.如果MongoDB for VS Code在您的扩展视图中隐藏,请显示它。
Create an Atlas Cluster from a Template using Terraform使用Terraform从模板创建Atlas集群MongoDB for VS Code SettingsMongoDB for VS Code设置