db.getMongo()

Important重要
mongosh Method

This is a mongosh method. This is not the documentation for Node.js or other programming language specific driver methods.

In most cases, mongosh methods work the same way as the legacy mongo shell methods. However, some legacy methods are unavailable in mongosh.

For the legacy mongo shell documentation, refer to the documentation for the corresponding MongoDB Server release:

For MongoDB API drivers, refer to the language specific MongoDB driver documentation.

db.getMongo()
Returns:返回:The current database connection.当前数据库连接。

db.getMongo() runs when the shell initiates. shell启动时运行。Use this command to test that mongosh has a connection to the proper database instance.使用此命令测试mongosh是否连接到正确的数据库实例。

Note注意

The legacy mongo shell has a sub-command, db.getMongo().setSecondaryOk(), which is not available in mongosh. 旧版mongo shell有一个子命令db.getMongo().setSecondaryOk(),该命令在mongosh中不可用。In mongosh, use Mongo.setReadPref() instead.mongosh中,请改用Mongo.setReadPref()

←  db.getLogComponents()db.getName() →