Docs HomeMongoDB for VS Code

MongoDB for VS Code Settings

Note

Preview预览

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

This document lists the configurable settings for MongoDB for VS Code.本文档列出了MongoDB for VS Code的可配置设置。

Configure Settings配置设置

To configure MongoDB for VS Code settings:要为VS Code设置配置MongoDB,请执行以下操作:

1

Open the Settings View.打开“设置”视图。

Operating System操作系统Method方法Actions操作
AnyVisual Studio Code MenuFile / Code > Preferences > Settings
MacOSKeyboard Shortcut键盘快捷方式Press Command + ,
Windows and LinuxKeyboard Shortcut键盘快捷方式Press Ctrl + ,
2

Search "MongoDB" in the Settings search bar.在“设置”搜索栏中搜索“MongoDB”。

MongoDB for VS Code extension settings are displayed. Changes you make are saved automatically.将显示MongoDB for VS Code扩展设置。您所做的更改将自动保存。

Settings设置

The following table lists the available settings for MongoDB for VS Code:下表列出了MongoDB for VS Code的可用设置:

Setting背景Description描述Default违约
ShellMongoDB shell to use. 要使用的MongoDB shell。Choose either:选择其中一个:
  • mongo (the legacy MongoDB shell), or
  • mongosh (the new MongoDB shell)
Important

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

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

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: 另请参阅:

  • To install the legacy mongo shell, see The mongo Shell.要安装遗留的mongoshell,请参阅mongoShell
  • To install the mongosh shell and for instructions on configuring your PATH variable, see Install the MongoDB Shell.要安装mongoshshell以及有关配置PATH变量的说明,请参阅安装MongoDB shell。
mongosh
ShowIf enabled, shows the MongoDB view in the Visual Studio Code left navigation panel.如果启用,则在Visual Studio Code左侧导航面板中显示MongoDB视图。Enabled已启用
Max Number of Problems最大问题数The maximum number of problems MongoDB for VS Code will generate in the Visual Studio Code Problems view.MongoDB for VS Code将在Visual Studio Code problems视图中生成的最大问题数。100
Trace: ServerMongoDB language server logging settings.MongoDB语言服务器日志记录设置。
Edit this setting through the mongodbLanguageServer.trace.server property in your project's settings.json file.通过项目的settings.json文件中的mongodbLanguageServer.trace.server属性编辑此设置。
Within the mongodbLanguageServer.trace.server object, you can specify:mongodbLanguageServer.trace.server对象中,可以指定:

  • format, and
  • verbosity
Output logs are viewable by selecting MongoDB Language Server from the dropdown in the Output view, or with the Language Server Protocol Inspector.通过从“输出”视图的下拉菜单中选择MongoDB语言服务器,或使用 Language Server Protocol Inspector,可以查看输出日志。
{
"format": "json",
"verbosity": "verbose"
}
Confirm Run All确认全部运行If enabled, shows a confirmation message before running commands in a playground.如果启用,则在演练场上运行命令之前显示一条确认消息。Enabled已启用
Default Connection Saving Location默认连接保存位置Sets if and where new connections are saved.设置保存新连接的时间和位置。
You can select:您可以选择:

Setting背景Description描述
GlobalSave your connection globally in VS Code, so it can be accessed from any workspace.将您的连接全局保存在VS Code中,这样就可以从任何工作区访问它。
WorkspaceSave your connection in your workspace. You cannot access the connection from a different workspace.将连接保存在工作区中。无法从其他工作区访问连接。
SessionSave the connection for only this VS Code session. 只保存此VS Code会话的连接。The connection is lost when you close VS Code.关闭VS Code时,连接将丢失。
Global
Hide Option To Choose Where To Save New Connections隐藏选项选择保存新连接的位置If disabled, you are prompted to choose where to save each new connection.如果禁用,系统将提示您选择保存每个新连接的位置。
If enabled, new connections are automatically saved to the Default Connection Saving Location without prompt.如果启用,新连接将自动保存到默认连接保存位置,无需提示。
Enabled已启用
Default Limit默认限制Number of documents to fetch when viewing documents from a collection. Does not affect playground operations.查看集合中的文档时要获取的文档数。不影响演练场操作。10
Send Telemetry发送遥测If enabled, allows the collection of anonymous diagnostic and usage telemetry data to help improve MongoDB for VS Code.如果启用,则允许集合匿名诊断和使用遥测数据,以帮助改进MongoDB for VS Code。Enabled已启用
Use Default Template For Playground使用演练场的默认模板If enabled, playground files load with a template containing sample commands.如果启用,演练场文件将加载包含示例命令的模板。
If disabled, playground files load with an empty playground editor.如果禁用,则使用空的演练场编辑器加载演练场文件。

Enabled已启用