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