对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

db.getMongo()(mongosh方法)

重要

mongosh 方法

This page documents a mongosh method. This is not the documentation for a language-specific driver, such as Node.js.

如需了解 MongoDB API 驱动程序,请参阅特定语言的 MongoDB 驱动程序文档。

db.getMongo()
返回:

当前数据库连接。

db.getMongo() runs when the shell initiates. Use this command to test that mongosh has a connection to the proper database instance.

注意

The legacy mongo shell has a sub-command, db.getMongo().setSecondaryOk(), which is not available in mongosh. In mongosh, use Mongo.setReadPref() instead.

此方法可用于以下环境中托管的部署:

  • MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务

注意

所有 MongoDB Atlas 集群都支持此命令。有关 Atlas 对所有命令的支持的信息,请参阅不支持的命令

给本页内容打分

在此页面上