Warning
Experimental feature实验特性
This feature is experimental. MongoDB does not provide support for Snippets. This feature may be changed or removed at any time without prior notice.此功能是实验性的。MongoDB不支持代码段。此功能可能随时更改或删除,恕不另行通知。
Bugs are not expected, however should you encounter one, please open an issue in the GitHub repository for this project.预计不会出现错误,但如果您遇到错误,请在GitHub存储库中为此项目打开一个问题。
These options control the interaction between 这些选项控制mongosh and the package manager that tracks individual snippet packages. For more details about how a particular snippet works, see the documentation for that snippet.mongosh和跟踪单个代码段包的包管理器之间的交互。有关特定代码段如何工作的更多详细信息,请参阅该代码段的文档。
To modify the snippet configuration settings, use the following method:要修改代码段配置设置,请使用以下方法:
config.set('<OPTION>', '<VALUE>')
Configuration Options配置选项
snippetAutoload | boolean | true | |
snippetIndexSourceURLs | list | MongoDB Repository Index File |
|
snippetRegistryURL | string | MongoDB npm Registry | mongosh npm client uses to install snippetsmongosh npm客户端用于安装代码段的npm注册表 |
Update the configuration options using the config command, then restart 使用config命令更新配置选项,然后重新启动mongosh for the updates to take effect.mongosh以使更新生效。
Examples例子
Add a Second Registry添加第二个注册表
Configure a second, private registry for sensitive snippets by adding a URL to 通过添加一个URL到snippetIndexSourceURLs.snippetIndexSourceURLs,为敏感代码段配置第二个私有注册表。
config.set('snippetIndexSourceURLs',
'https://github.com/YOUR_COMPANY/PATH_TO_YOUR_REGISTRY/index.bson.br;'
+ config.get('snippetIndexSourceURLs')
)
Restart 重新启动mongosh for the update to take effect.mongosh以使更新生效。
Disable Snippets禁用代码段
The snippets feature requires an index source URL to function. Unset this value then restart 片段功能需要一个索引源URL才能运行。取消设置此值,然后重新启动mongosh to disable snippets.mongosh以禁用代码段。
config.set('snippetIndexSourceURLs', '')
Snippets can also be disabled from outside 片段也可以在mongosh. If you cannot start mongosh because of a corrupt snippets configuration, disable snippets and restart mongosh.mongosh之外禁用。如果由于代码段配置损坏而无法启动mongosh,请禁用代码段并重新启动mongos。
mongosh --nodb --eval 'config.set("snippetIndexSourceURLs", "")'