Docs HomeMongoDB Shell

Configure Settings配置设置

To specify certain shell behaviors, you can configure mongosh settings.要指定某些shell行为,可以配置mongosh设置。

Configurable Settings可配置设置

You can configure the following settings for mongosh:您可以为mongosh配置以下设置:

KeyType类型Default默认值Description描述
displayBatchSizeinteger20The number of items displayed per cursor iteration每次游标迭代显示的项目数
enableTelemetrybooleantrueEnables sending anonymized tracking and diagnostic data to MongoDB.允许向MongoDB发送匿名跟踪和诊断数据。
editorstringnullDesignates an editor to use within the mongosh console. 指定要在mongosh控制台中使用的编辑器。Overrides the EDITOR environment variable if set.覆盖EDITOR环境变量(如果已设置)。
forceDisableTelemetrybooleanfalseOnly available in the global configuration file. When true, users cannot enable telemetry manually.仅在全局配置文件中可用。如果为true,则用户无法手动启用遥测。
historyLengthinteger1000The number of items to store in mongosh REPL's history file.要存储在mongosh REPL的历史文件中的项目数。
inspectCompactinteger or boolean3The level of inner elements that mongosh outputs on a single line. mongosh在一行中输出的内部元素的级别。Short array elements are also grouped together on a single line.短数组元素也被分组在一条线上。
If set to false, mongosh outputs each field on its own line.如果设置为falsemongosh将在自己的行上输出每个字段。
inspectDepthinteger or Infinity6The depth to which objects are printed. 打印对象的深度。Setting inspectDepth to Infinity (the javascript object) prints all nested objects to their full depth.inspectDepth设置为Infinity(Javascript对象)会将所有嵌套对象打印到其全部深度。
redactHistorystringremove

Controls what information is recorded in the shell history. 控制shell历史记录中记录的信息。Must be one of:必须是以下其中之一:

  • keep: Retain all history.:保留所有历史记录。
  • remove: Remove lines which contain sensitive information.:删除包含敏感信息的行。
  • remove-redact: Redact sensitive information.:重新处理敏感信息。
showStackTracesbooleanfalseControls display of a stack trace along with error messages.控制堆栈跟踪以及错误消息的显示。
snippetAutoloadbooleantrueIf true, automatically load installed snippets at startup.如果为true,则在启动时自动加载已安装的代码段
snippetIndexSourceURLsstringMongoDB RepositoryA semicolon-separated list of URLs that link to a snippet registry.链接到代码段注册表的URL的分号分隔列表。
snippetRegistryURLstringnpm RegistryThe npm registry used by the mongosh npm client that installs snippet.安装snippetmongosh npm客户端使用的npm注册表。

How to Configure Settings如何配置设置

To configure mongosh settings, you can either use:要配置mongosh设置,您可以使用: